Reputation: 45320
Running Terraform v0.11.3 and I am trying to merge two maps into a single map using the merge()
function. However I can't get the syntax right. Does merge()
support using dynamic variables?
tags = "${merge({
Name = "${var.name}"
Env = "${var.environment}"
AutoSnapshot = "${var.auto_snapshot}"
}, "${var.tags}")}"
Upvotes: 14
Views: 29177
Reputation: 535
In Terraform > 0.12 this can be done as:
tags = merge(tomap({
Name = var.name,
Env = var.environment,
AutoSnapshot = var.auto_snapshot }),
var.tags,
)
Upvotes: 23