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.
The ignore_changes should be set at the resource level, not the provider.
Example:
resource "aws_instance" "web" {
ami = "ami-0c94855ba95c574c8"
instance_type = "t3.micro"
lifecycle {
ignore_changes = [
tags
]
}
}
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.