ignore_changes tells Terraform to stop correcting certain attributes of a resource. It is the right tool when something else legitimately owns a value, such as an autoscaler or a deploy pipeline. It is the wrong tool when someone changed a resource in the console and the next plan wanted to put it back. In that case it hides drift instead of fixing it.
This guide covers the syntax, the cases where it belongs, ignoring tags, the common errors, and how to keep it from becoming a place where drift goes unnoticed.
How ignore_changes works
ignore_changes lives in a resource's lifecycle block and takes a list of attribute names:
resource "aws_ecs_service" "api" { name = "api" cluster = aws_ecs_cluster.main.id task_definition = aws_ecs_task_definition.api.arn desired_count = 2 lifecycle { ignore_changes = [desired_count] } } Terraform uses desired_count = 2 when it creates the service. After that, if the real value changes (here, because Application Auto Scaling scaled the service to 6), terraform plan no longer proposes setting it back to 2.
Three details matter:
- It only affects updates. The value in your code is still used when the resource is created or replaced.
- Terraform still reads the real value. A refresh records it in state, so
terraform state show aws_ecs_service.apishowsdesired_count = 6. The plan simply doesn't act on it. - Changing the code doesn't change the resource either. If you later edit
desired_countto 4, nothing happens, because the attribute is ignored in both directions.
When ignore_changes is the right tool
Use it when another system owns the value on purpose, and that ownership is stable:
| Resource | Attribute | Who really owns it |
|---|---|---|
aws_autoscaling_group | desired_capacity | Scaling policies |
aws_ecs_service | desired_count | Application Auto Scaling |
aws_ecs_service | task_definition | A CI pipeline that deploys new task definitions |
aws_lambda_function | image_uri or code hash | A deploy tool outside Terraform |
aws_db_instance | password | Secrets Manager rotation |
| Any resource | Specific tags | Tools that tag resources after creation (cost, backup, security scanners) |
In each case the change outside Terraform is expected, repeats, and is correct. Fighting it would make every plan noisy and every apply risky.
Ignoring tags, or just one tag
Ignoring all tags is a common overreach:
lifecycle { ignore_changes = [tags] } That also ignores tags your team changes in code, such as Owner or CostCenter. Ignore only the keys another tool writes:
lifecycle { ignore_changes = [tags["LastBackup"], tags["ScannerVersion"]] } On AWS, if a tool adds the same tags everywhere, configure it once in the provider instead of in every resource:
provider "aws" { region = "us-east-1" ignore_tags { keys = ["LastBackup"] key_prefixes = ["scanner:"] } } ignore_changes = all
lifecycle { ignore_changes = all } This tells Terraform to create the resource and then never update it. It is occasionally useful for a resource you want created once and handed over to another team. For anything else it is a trap: the resource looks managed, appears in state, and silently stops matching your code.
Common errors and limits
It can't be conditional. This fails:
lifecycle { ignore_changes = var.autoscaling ? [desired_count] : [] # not allowed } ignore_changes only accepts static attribute names, not expressions or variables. If you need both behaviours, define two versions of the resource and pick one with count, or move the decision into separate modules.
It can't be set from outside a module. A module caller cannot add ignore_changes to resources inside the module. The lifecycle block has to be in the module's own resource. If you maintain the module, expose the choice as two resource variants as above.
The attribute name must exist. ignore_changes = [desired_capacity] on a resource that has no such attribute is an error. Check the provider docs for the exact name.
How ignore_changes hides drift
The problem starts when ignore_changes is added to silence a plan nobody understood:
- Someone opens port 22 on a security group in the console during an incident.
- The next plan wants to remove the rule.
- To get the deploy through, someone adds
ignore_changes = [ingress]. - The port stays open, and no plan will ever mention it again.
That's not a lifecycle rule; it's an unreviewed exception with no expiry. The same pattern shows up with IAM policies, bucket policies and encryption settings, exactly the attributes where a silent change matters most.
How to use ignore_changes safely
- Write down why. Add a comment next to every
ignore_changessaying which system owns the value. If nobody can name one, the rule probably shouldn't exist. - Never ignore security attributes. Security group rules, IAM policies, bucket policies, encryption and public-access settings should be fixed in code, not ignored.
- Review the list. Search your code for
ignore_changesevery quarter. Each entry should still have an owner. - Keep checking ignored attributes for drift. Because Terraform still records the real values in state, a scheduled check can compare them with what you expect. The Terraform drift detection guide shows how to run one, and
terraform plan -refresh-onlyis the safest way to see what changed. - Decide what to do with each drift finding: update the code, revert the change, or accept it with an expiry. The drift triage playbook covers the decision.
Where OrchesTerra fits
ignore_changes exists because teams need some way to deal with changes made outside Terraform. OrchesTerra handles those changes directly instead. It checks your AWS accounts against your Terraform on a schedule and ranks each difference by risk, so an extra tag ranks low and a port opened to the internet ranks high. Each finding goes through an approval: update the code, revert the change, or accept it with an expiry date. Nothing gets hidden permanently.
You can see it in the read-only demo without signing up.
To see what is still drifting after your ignore_changes rules, run a refresh-only check. The free, open-source cloud-drift-report CLI does that and ranks each change, so a security change that should never be ignored stands out.
Quick checklist
- Use
ignore_changesonly when another system owns the value on purpose. - Ignore single tag keys, not
tags, and use the AWS provider'signore_tagsfor tags added everywhere. - Avoid
ignore_changes = allunless you mean "create once, then hand over". - Never use it to silence security changes; fix them in code.
- Comment each entry with its owner, and review the list regularly.
Originally published on the OrchesTerra blog.