github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/website/docs/configuration/functions/length.html.md (about)

     1  ---
     2  layout: "functions"
     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  -> **Note:** This page is about Terraform 0.12 and later. For Terraform 0.11 and
    12  earlier, see
    13  [0.11 Configuration Language: Interpolation Syntax](../../configuration-0-11/interpolation.html).
    14  
    15  `length` determines the length of a given list, map, or string.
    16  
    17  If given a list or map, the result is the number of elements in that collection.
    18  If given a string, the result is the number of characters in the string.
    19  
    20  ## Examples
    21  
    22  ```
    23  > length([])
    24  0
    25  > length(["a", "b"])
    26  2
    27  > length({"a" = "b"})
    28  1
    29  > length("hello")
    30  5
    31  ```
    32  
    33  When given a string, the result is the number of characters, rather than the
    34  number of bytes or Unicode sequences that form them:
    35  
    36  ```
    37  > length("👾🕹️")
    38  2
    39  ```
    40  
    41  A "character" is a _grapheme cluster_, as defined by
    42  [Unicode Standard Annex #29](http://unicode.org/reports/tr29/). Note that
    43  remote APIs may have a different definition of "character" for the purpose of
    44  length limits on string arguments; a Terraform provider is responsible for
    45  translating Terraform's string representation into that used by its respective
    46  remote system and applying any additional validation rules to it.