github.com/hugorut/terraform@v1.1.3/website/docs/language/functions/length.mdx (about) 1 --- 2 page_title: length - Functions - Configuration Language 3 description: The length function determines the length of a collection or string. 4 --- 5 6 # `length` Function 7 8 `length` determines the length of a given list, map, or string. 9 10 If given a list or map, the result is the number of elements in that collection. 11 If given a string, the result is the number of characters in the string. 12 13 ## Examples 14 15 ``` 16 > length([]) 17 0 18 > length(["a", "b"]) 19 2 20 > length({"a" = "b"}) 21 1 22 > length("hello") 23 5 24 ``` 25 26 When given a string, the result is the number of characters, rather than the 27 number of bytes or Unicode sequences that form them: 28 29 ``` 30 > length("👾🕹️") 31 2 32 ``` 33 34 A "character" is a _grapheme cluster_, as defined by 35 [Unicode Standard Annex #29](http://unicode.org/reports/tr29/). Note that 36 remote APIs may have a different definition of "character" for the purpose of 37 length limits on string arguments; a Terraform provider is responsible for 38 translating Terraform's string representation into that used by its respective 39 remote system and applying any additional validation rules to it.