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

     1  ---
     2  layout: "functions"
     3  page_title: "tomap - Functions - Configuration Language"
     4  sidebar_current: "docs-funcs-conversion-tomap"
     5  description: |-
     6    The tomap function converts a value to a map.
     7  ---
     8  
     9  # `tomap` 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  `tomap` converts its argument to a map value.
    16  
    17  Explicit type conversions are rarely necessary in Terraform because it will
    18  convert types automatically where required. Use the explicit type conversion
    19  functions only to normalize types returned in module outputs.
    20  
    21  ## Examples
    22  
    23  ```
    24  > tomap({"a" = 1, "b" = 2})
    25  {
    26    "a" = 1
    27    "b" = 2
    28  }
    29  ```
    30  
    31  Since Terraform's concept of a map requires all of the elements to be of the
    32  same type, mixed-typed elements will be converted to the most general type:
    33  
    34  ```
    35  > tomap({"a" = "foo", "b" = true})
    36  {
    37    "a" = "foo"
    38    "b" = "true"
    39  }
    40  ```