Files
opentf/website/docs/configuration/functions/map.html.md
Nick Fagerlund 5e18e44037 Merge pull request #26723 from hashicorp/oct20_language_and_cli_docs
website: TF-153: Split core Terraform docs into "Language" and "CLI"
2020-11-11 19:31:05 -08:00

1.1 KiB

layout, page_title, sidebar_current, description
layout page_title sidebar_current description
language map - Functions - Configuration Language docs-funcs-collection-map The map function constructs a map from some given elements.

map Function

-> Note: This page is about Terraform 0.12 and later. For Terraform 0.11 and earlier, see 0.11 Configuration Language: Interpolation Syntax.

The map function is no longer available. Prior to Terraform v0.12 it was the only available syntax for writing a literal map inside an expression, but Terraform v0.12 introduced a new first-class syntax.

To update an expression like map("a", "b", "c", "d"), write the following instead:

tomap({
  a = "b"
  c = "d"
})

The { ... } braces construct an object value, and then the tomap function then converts it to a map. For more information on the value types in the Terraform language, see Type Constraints.

  • tomap converts an object value to a map.
  • zipmap constructs a map dynamically, by taking keys from one list and values from another list.