How to define lifecycle check to avoid redeployment of resources if tags are changed
When i am using:
terraform {
required_version = ">=1.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "5.0.0"
}
}
}
provider "aws" {
region = var.aws_region
lifecycle {
ignore_changes = [
# Ignore changes to tags, e.g. because a management agent
# updates these based on some ruleset managed elsewhere.
tags,
]
}
}
I am getting error:
The block type name "lifecycle" is reserved for use by Terraform in a future version.
2
Answers
Terraform doesn't redeploy resources if tags are added or removed.
The ignore_changes should be set at the resource level, not the provider.
Example:
Some notes:
all
may be used to instruct Terraform to ignore all attributes, which means that Terraform can create and destroy the remote object but will never propose updates to it.ignore_changes
cannot be applied to itself or to any other meta-arguments.