...
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.13
Code Block |
---|
title | Recent Terraform Versions (>= v0.13) |
---|
|
code |
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"],
]
}
} |
The next time you run Terraform plan/apply, Terraform will ignore any of those tags.
Terraform Version 0.12.x
TBD
Terraform Versions 0.11.x
Code Block |
---|
|
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",
]
}
} |
Warning |
---|
If your Terraform version doesn't allow you to name specific tags, you can tell it to ignore all tag changes: Code Block |
---|
lifecycle {
ignore_changes = [ tags ]
} |
Or |
Warning |
---|
You must be using Terraform version 0.14.1 or later to specify specific tags (i.e. tags["just-this-tag"] ) in the ignore_changes attribute. If you are using any Terraform version prior to that, you will have to tell Terraform to ignore changes to all tags: Code Block |
---|
lifecycle {
ignore_changes = [ "tags" ]
} |
|
References