You can use terraform lookup() function to get value of an element from a map based on key. lookup() retrieves the value of a single element from a map, given its key. If the given key does not exist, the given default value is returned instead.
Syntax: lookup(map, key, default)
Example:
1 2 3 4 5 6 7 8 |
## Open terraform console terraform console ## Get value of an element from a map based on key lookup({a=1, c=2, d=3}, "c", "not found") ## returns 2 lookup({a=1, c=2, d=3}, "b", "not found") ## returns "not found" |