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

     1  ---
     2  layout: "functions"
     3  page_title: "keys - Functions - Configuration Language"
     4  sidebar_current: "docs-funcs-collection-keys"
     5  description: |-
     6    The keys function returns a list of the keys in a given map.
     7  ---
     8  
     9  # `keys` 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  `keys` takes a map and returns a list containing the keys from that map.
    16  
    17  The keys are returned in lexicographical order, ensuring that the result will
    18  be identical as long as the keys in the map don't change.
    19  
    20  ## Examples
    21  
    22  ```
    23  > keys({a=1, c=2, d=3})
    24  [
    25    "a",
    26    "c",
    27    "d",
    28  ]
    29  ```
    30  
    31  ## Related Functions
    32  
    33  * [`values`](./values.html) returns a list of the _values_ from a map.