Every plan wants to change `desired_capacity` on an Auto Scaling group back to 2, though autoscaling has raised it to 6.
BeginnerTroubleshootingLost, Corrupted and Drifted State
Answer
Likely causes → Terraform manages an attribute that something else (scaling policies, Karpenter, a human) also manages. That's expected drift, not a Terraform bug.
Diagnose → terraform plan shows ~ desired_capacity = 6 -> 2.
Fix →
resource "aws_autoscaling_group" "web" {
# ...
lifecycle {
ignore_changes = [desired_capacity]
}
}
Or don't set desired_capacity at all.
Prevent → For every attribute, pick one owner. Same pattern for ECS desired_count with service autoscaling.
More on Lost, Corrupted and Drifted State
Someone deleted the state object from the S3 bucket. `terraform plan` now wants to create 140 resources that already exist.IntermediateState is gone and the bucket had no versioning. How do you recover a production stack?Advanced`Error: Failed to load state` followed by a JSON error like `invalid character '}' looking for beginning of object key string`.IntermediateThe plan prints `Note: Objects have changed outside of Terraform` and lists a security group with an extra ingress rule.BeginnerA resource was deleted manually in the console. The plan wants to create it, and an apply fails because a dependent resource still references the old ID.Intermediate`terraform plan -refresh-only` shows drift, and you apply it. The next normal plan still wants to revert the change. Why?Intermediate