I greatly appreciate the hint. This was exactly what I needed and gets me a lot closer to what I need to do. The docs could use an example like this with something more than just “string.”
I’m not sure if I’m encountering a bug here or not but your example for “Name” generates the following vague error if the map doesn’t contain the key “Name” at all. Shouldn’t it return
| var.tags is map of string with 1 element
The given key does not identify an element in this collection value.
If I wrap the condition below in can() it fixes that problem but then it doesn’t properly validate the value and incorrectly succeeds even if the value has upper case characters. Am I missing something?
can(var.tags["Name"] == lower(var.tags["Name"]))
Because the first condition would fail if the key “Name” were missing, why is the second condition even being evaluated at all?