After an incident, someone changed an EC2 instance type in the console. `terraform plan` now wants to stop and resize it back during business hours.
BeginnerTroubleshootingLost, Corrupted and Drifted State
Answer
Likely causes → Drift on instance_type; the AWS provider changes it in place by stopping and starting the instance.
Diagnose → terraform plan shows ~ instance_type = "m6i.xlarge" -> "m6i.large".
Fix → If the bigger size is now correct, update code and apply (no-op). If not, schedule the resize in a maintenance window.
Prevent → Incident runbooks must include "open a PR to codify any manual change within 24 hours".
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.BeginnerEvery plan wants to change `desired_capacity` on an Auto Scaling group back to 2, though autoscaling has raised it to 6.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