Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The given key does not identify an element in this collection value: the collection has no elements. #24

Open
gfysaris opened this issue Feb 11, 2024 · 1 comment

Comments

@gfysaris
Copy link

Hello all,
First of all let me take some time to thank you for all your hard work you've put into creating and maintaining this module!

As a first time user of this module, i came accross an error that i was able to fix by altering a signle line of the module. Based on my terraform experience the change i made makes sense, but i am reaching out to you, about this change, since i find it very weird that this change is required for my project in order for it to work.

So the error i was getting was the following:

│ Error: Invalid index
│
│   on .terraform\modules\lz_template_policies\policies\network_cmp_policy.tf line 91, in locals:
│   91:   application_compartment_id = local.enable_oke_service_policies ? (distinct(compact(concat([for k, values in local.cmp_name_to_cislz_tag_map : (contains(split(",",values["cmp-type"]),"application")) ? values["ocid"] : ""])))[0]) : null
│     ├────────────────
│     │ local.cmp_name_to_cislz_tag_map is object with 3 attributes

Original line 91 of the network_cmp_policy.tf is the following:

application_compartment_id = local.enable_oke_service_policies ? (distinct(compact(concat([for k, values in local.cmp_name_to_cislz_tag_map : (contains(split(",",values["cmp-type"]),"application")) ? values["ocid"] : ""])))[0]) : null

The change i had to make to make this work was just to remove [0] as i could not identify the purpose of it there.
After this change everything work.

Please let me know if i misunderstood something or what i am doing wrong and i can not make this module work with this change.

Thank you

@andrecorreaneto
Copy link
Member

Hi gfysaris, sorry for the late return. We will check into this. Thanks for reporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants