Files
opentf/website/docs/configuration/functions/merge.html.md
Nick Fagerlund 596e529602 website: Adopt a ton of pages into the "language" layout
As of this commit, that layout doesn't exist yet, but I'm isolating the one-line
changes to their own commit to try and keep your eyes from glazing over.
2020-10-26 18:19:26 -07:00

1.2 KiB

layout, page_title, sidebar_current, description
layout page_title sidebar_current description
language merge - Functions - Configuration Language docs-funcs-collection-merge The merge function takes an arbitrary number maps or objects, and returns a single map or object that contains a merged set of elements from all arguments.

merge Function

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

merge takes an arbitrary number of maps or objects, and returns a single map or object that contains a merged set of elements from all arguments.

If more than one given map or object defines the same key or attribute, then the one that is later in the argument sequence takes precedence. If the argument types do not match, the resulting type will be an object matching the type structure of the attributes after the merging rules have been applied.

Examples

> merge({a="b", c="d"}, {e="f", c="z"})
{
  "a" = "b"
  "c" = "z"
  "e" = "f"
}
> merge({a="b"}, {a=[1,2], c="z"}, {d=3})
{
  "a" = [
    1,
    2,
  ]
  "c" = "z"
  "d" = 3
}