How to get the length of a string map list variable in terraform?

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: