How to handle map of maps in terraform if key is not present
I am having a map of maps, and if the key is not present getting below error:
var.mapofmaps is map of map of string with 4 elements
The given key does not identify an element in this collection value
Can you help me how to handle map of maps if key is not present. I also tried with lookup() but it only works for map but not for map of maps.
Hi @bptambake,
It would help to share the code you already have and the full error message you saw when you tried it. Your current question is vague and so hard to answer.
I’m hoping that seeing your code will make it clearer what you intend to have happen when the specified key is not present, but it would also help if you can describe exactly what result you want your code to have; there are lots of different reasonable things to do when a map element isn’t present, depending on your goals.