merge()
The function that combines several maps into one, with keys in later maps winning over earlier ones.
In more detail
The usual pattern is merge(var.tags, { ManagedBy = "terraform" }): the caller's tags plus the ones the configuration insists on. Put the values that must win last.
Example
tags = merge(var.tags, { ManagedBy = "terraform" })Related terms
- built-in function — One of Terraform's fixed set of functions, such as lower(), join() or jsonencode(), that transform values inside expressions.
- resource tag — A key and value label, such as Role=web or Environment=production, attached to a cloud resource to describe it.
Taught in
- Return Values: Outputs And Locals — Infrastructure as Code with Terraform
- Functions And Expressions In HCL — Infrastructure as Code with Terraform