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