github.com/hugorut/terraform@v1.1.3/website/docs/language/functions/merge.mdx (about) 1 --- 2 page_title: merge - Functions - Configuration Language 3 description: |- 4 The merge function takes an arbitrary number maps or objects, and returns a 5 single map or object that contains a merged set of elements from all 6 arguments. 7 --- 8 9 # `merge` Function 10 11 `merge` takes an arbitrary number of maps or objects, and returns a single map 12 or object that contains a merged set of elements from all arguments. 13 14 If more than one given map or object defines the same key or attribute, then 15 the one that is later in the argument sequence takes precedence. If the 16 argument types do not match, the resulting type will be an object matching the 17 type structure of the attributes after the merging rules have been applied. 18 19 ## Examples 20 21 ``` 22 > merge({a="b", c="d"}, {e="f", c="z"}) 23 { 24 "a" = "b" 25 "c" = "z" 26 "e" = "f" 27 } 28 ``` 29 30 ``` 31 > merge({a="b"}, {a=[1,2], c="z"}, {d=3}) 32 { 33 "a" = [ 34 1, 35 2, 36 ] 37 "c" = "z" 38 "d" = 3 39 } 40 ```