The New "Local Values" Tutorial Left Me Scratching My Head

I appreciated the new “Local Values” tutorial. It delivered some nice ideas. But then left me feeling let down by the “tags” example.

Theoretically, the “tags” example would have been a perfect tutorial selection. Most of the time, you want a combination of

  1. standard, required tags, with universal values (ex: “Environment” = “dev”),
  2. standard tags, but with resource-specific tags (ex: “Name” = “My EC2 Instance”), and
  3. resource-specific tag and values (ex: “AWS_Pipeline” = “EC2_Pipeline”).

The way that the variable resource_tags was defined and used in the tutorial initially seemed to imply that each resource was going to define a set of resource-specific tags. And then that set of resource-specific tags would be seamlessly combined with the required_tags, via local.tags.

  • variable “resource_tags” {
  • type = map(string)
  • default = {}
  • }

However, all that the resource_tag really seems to do is provide a second set of required tags, with the resource_tags having the added complexity of requiring that it be passed in at runtime.

I am hoping that I have missed something; but so far, this appears to be the only way to allow the local resources to be able to append resource-specific tag values.

  • resource “provider_resource” “my_resource” {
    • tags = (merge(
    • local.tags,
    • tomap({
    • “Name” = “${local.name_prefix_long}-${var.vpc_name}”,
    • “Accredited” = true
  • })
  • ))
  • }

BTW: It would be nice to have both a “before” and “after” branch on the git repository.