Member-only story

Tagging in Terraform on AWS — Merging maps and inline tags!

Jack Roper
May 12, 2020

--

How to use a terraform map of tags and combine it with an inline tag?

For example, we have a tag called Name, for an AWS Elastic IP.

Name = ${var.host}-cluster_ip

We also have a definition of local values as follows:

Define the tags in the resource as follows to combine the 2…

tags = “${merge(map(“Name”, “${var.host}-cluster_ip”,), local.extra_tags)}”

This technique can be used to merge multiple maps and tags read in from other files, e.g. a ‘global_settings’ block that can be defined at the root module level.

Want more Terraform content? Check out my other articles on Terraform here!

Cheers! 🍻

--

--

Jack Roper
Jack Roper

Written by Jack Roper

A blog about DevOps & Cloud Tech. Specializing in Terraform, Kubernetes, GitHub, Azure & Azure DevOps! ☁️

No responses yet