Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

You can tell Terraform to ignore those tags by adding a lifecycle stanza to the resource and setting the ignore_changes attribute as shown below. The next time you run Terraform plan/apply, Terraform will ignore any of those tags.

Terraform Versions >= 0.

...

12.3

Code Block
titleRecent Terraform Versions (>= v0.13)
resource "aws_subnet" "example" {
  cidr_block        = "10.92.117.128/25"
  vpc_id            = aws_vpc.example.id

  ... 

  tags = {
    Name = "example-subnet"
  }

  lifecycle {
    ignore_changes = [
      tags["cit:dc-arch-migration-description"],
      tags["cit:dc-arch-migration-target"],
      tags["cit:dc-arch-version"],
      tags["cit:dc-vgw"],
      tags["cit:subnet-type"],
      tags["cit:tgw-attachment-target"],
    ]
  }
}

Terraform Version 0.12.0 through 0.12.

...

2

You will need to upgrade Terraform to at least version 0.12.3 and then use the configuration above.(error) TBD

Terraform Versions 0.11.x

Code Block
titleTerraform v0.11.x
resource "aws_subnet" "example" {
  cidr_block        = "10.92.117.128/25"
  vpc_id            = aws_vpc.example.id

  ... 

  tags = {
    Name = "example-subnet"
  }

  lifecycle {
    ignore_changes = [
	  "tags.%",
      "tags.cit:dc-arch-migration-description",
      "tags.cit:dc-arch-migration-target",
      "tags.cit:dc-arch-version",
      "tags.cit:dc-vgw",
      "tags.cit:subnet-type",
      "tags.cit:tgw-attachment-target",
    ]
  }
}

Last Ditch

...

Options

If your Terraform version or AWS provider version doesn't

...

support (or behave as expected) with the options above, you should be able to, at least, tell Terraform to ignore all

...

changes to tags, as shown below:

Code Block
   lifecycle {
     ignore_changes = [ tags ]
   } 

Or...

Code Block
   lifecycle {
     ignore_changes = [ "tags" ]
   } 

References

...