0
0
Terraformcloud~10 mins

Ignore_changes lifecycle rule in Terraform - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Ignore_changes lifecycle rule
Start Terraform Apply
Check resource config changes
Is attribute in ignore_changes?
YesSkip updating that attribute
No
Apply changes to resource
Finish Apply
Terraform checks resource changes, skips updates to attributes listed in ignore_changes, then applies other changes.
Execution Sample
Terraform
resource "aws_instance" "example" {
  ami           = "ami-123456"
  instance_type = "t2.micro"
  tags = {
    Name = "new"
  }

  lifecycle {
    ignore_changes = ["tags"]
  }
}
This resource ignores changes to the 'tags' attribute during terraform apply.
Process Table
StepResource AttributeChange DetectedIn ignore_changes?Action Taken
1amiChanged from ami-111111 to ami-123456NoUpdate applied
2instance_typeNo changeNoNo action
3tagsChanged from {Name=old} to {Name=new}YesChange ignored
4Apply complete--Resource updated except tags
💡 All changes processed; tags change ignored due to lifecycle ignore_changes rule.
Status Tracker
AttributeInitial ValueDetected ChangeFinal Applied Value
amiami-111111ami-123456ami-123456
instance_typet2.microt2.microt2.micro
tags{Name=old}{Name=new}{Name=old}
Key Moments - 2 Insights
Why does Terraform not update the 'tags' attribute even though it changed?
Because 'tags' is listed in ignore_changes, Terraform skips updating it as shown in execution_table step 3.
Does ignore_changes prevent Terraform from detecting changes?
No, Terraform detects changes but skips applying them for attributes in ignore_changes, as seen in step 3.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what happens at step 1 for the 'ami' attribute?
ANo change detected
BChange ignored
CUpdate applied
DError occurs
💡 Hint
Check the 'Action Taken' column at step 1 in execution_table.
At which step does Terraform skip applying a change due to ignore_changes?
AStep 1
BStep 3
CStep 2
DStep 4
💡 Hint
Look for 'Change ignored' in the 'Action Taken' column in execution_table.
If 'tags' were removed from ignore_changes, what would happen at step 3?
ATerraform would apply the tags change
BChange ignored as before
CTerraform would error out
DNo change detected
💡 Hint
Refer to variable_tracker and execution_table to see how ignore_changes affects applying changes.
Concept Snapshot
Terraform lifecycle ignore_changes rule:
- Syntax: lifecycle { ignore_changes = ["attribute"] }
- Terraform detects changes but skips applying listed attributes
- Useful to avoid overwriting manual or external changes
- Applies only during terraform apply
- Other attributes update normally
Full Transcript
Terraform's ignore_changes lifecycle rule tells Terraform to detect but not apply changes to specified resource attributes. When Terraform runs apply, it compares current and desired states. If an attribute is in ignore_changes, Terraform skips updating it even if it changed. This helps keep manual or external changes intact. Other attributes update normally. For example, if tags are ignored, Terraform will not overwrite tag changes but will update other attributes like ami or instance_type.