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

How to handle map of maps in terraform if key is not present #334

Open
bptambake opened this issue Jun 23, 2023 · 0 comments
Open

How to handle map of maps in terraform if key is not present #334

bptambake opened this issue Jun 23, 2023 · 0 comments

Comments

@bptambake
Copy link

//list of keys
keys=[key1,key2,key3,key4,key5,key6,key7]

//map of maps
"map-of-maps":
{
"key1":
{
"k1": "v1"
},
"key3":
{
"k3": "v3"
},
"key4":
{
"k4": "v4"
},
"key6":
{
"k6": "v6"
}

}

i want to Iterate for the keys on this map-of-maps, but few of the key present in keys dont have corresponding value in map-of-maps and it is throwing error.
I need to handle the exception, if the key is not present in map-of-maps, it should return empty.

example: key5 is present in the list and it is not present in map-of-maps, while iterating using for loop it is throwing error.

var.mapofmaps is map of map of string with 4 elements
The given key does not identify an element in this collection value

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

1 participant