2018-05-12 18:39:29 +02:00
|
|
|
---
|
2021-11-23 00:57:25 +01:00
|
|
|
layout: "language"
|
|
|
|
page_title: "map - Functions - Configuration Language"
|
|
|
|
sidebar_current: "docs-funcs-collection-map"
|
|
|
|
description: |-
|
|
|
|
The map function constructs a map from some given elements.
|
2018-05-12 18:39:29 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
# `map` Function
|
|
|
|
|
2020-11-04 22:18:44 +01:00
|
|
|
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.
|
2018-05-12 18:39:29 +02:00
|
|
|
|
2020-11-04 22:18:44 +01:00
|
|
|
To update an expression like `map("a", "b", "c", "d")`, write the following instead:
|
2018-05-12 18:39:29 +02:00
|
|
|
|
|
|
|
```
|
2020-11-04 22:18:44 +01:00
|
|
|
tomap({
|
|
|
|
a = "b"
|
|
|
|
c = "d"
|
|
|
|
})
|
2018-05-12 18:39:29 +02:00
|
|
|
```
|
|
|
|
|
2020-11-04 22:18:44 +01:00
|
|
|
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
|
2021-11-23 00:57:25 +01:00
|
|
|
Terraform language, see [Type Constraints](/docs/language/expressions/types.html).
|
2019-01-17 18:11:48 +01:00
|
|
|
|
|
|
|
## Related Functions
|
|
|
|
|
2021-11-23 00:57:25 +01:00
|
|
|
* [`tomap`](./tomap.html) converts an object value to a map.
|
|
|
|
* [`zipmap`](./zipmap.html) constructs a map dynamically, by taking keys from
|
2020-11-04 22:18:44 +01:00
|
|
|
one list and values from another list.
|