You can use terraform function length() to get the length of a string, map, list, or variable. length() determines the length of a given list, map, or string.
Syntax: length(data)
Example:
1 2 3 4 5 6 7 8 9 10 11 12 |
## Open terraform console terraform console ## Get length of a string length("cloudaffaire") ## returns 12 ## Get length of a list length([1,2,3,4,5]) ## returns 5 length(["aws","gcp"]) ## returns 2 ## Get length of a map length({a=1, c=2, d=3}) ## returns 3 |