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

     1  ---
     2  layout: "functions"
     3  page_title: "zipmap - Functions - Configuration Language"
     4  sidebar_current: "docs-funcs-collection-zipmap"
     5  description: |-
     6    The zipmap function constructs a map from a list of keys and a corresponding
     7    list of values.
     8  ---
     9  
    10  # `zipmap` Function
    11  
    12  -> **Note:** This page is about Terraform 0.12 and later. For Terraform 0.11 and
    13  earlier, see
    14  [0.11 Configuration Language: Interpolation Syntax](../../configuration-0-11/interpolation.html).
    15  
    16  `zipmap` constructs a map from a list of keys and a corresponding list of
    17  values.
    18  
    19  ```hcl
    20  zipmap(keyslist, valueslist)
    21  ```
    22  
    23  Both `keyslist` and `valueslist` must be of the same length. `keyslist` must
    24  be a list of strings, while `valueslist` can be a list of any type.
    25  
    26  Each pair of elements with the same index from the two lists will be used
    27  as the key and value of an element in the resulting map. If the same value
    28  appears multiple times in `keyslist` then the value with the highest index
    29  is used in the resulting map.
    30  
    31  ## Examples
    32  
    33  ```
    34  > zipmap(["a", "b"], [1, 2])
    35  {
    36    "a" = 1,
    37    "b" = 2,
    38  }
    39  ```