`terraform state list` shows `aws_instance.web` but the plan says `aws_instance.web will be destroyed` with `(because aws_instance.web is not in configuration)`.
BeginnerTroubleshootingLost, Corrupted and Drifted State
Answer
Likely causes → The block was deleted or renamed in code, or it lives in a file that isn't in this directory (moved to a module, or a file renamed to .tf.bak).
Diagnose → grep -rn 'resource "aws_instance" "web"' .
Fix → If renamed or moved into a module, add a moved block. If intentionally removed from management without destroying it, use a removed block with lifecycle { destroy = false }. If it should be destroyed, apply.
Prevent → Treat any unexpected destroy in plan as a blocker in review; add a CI check that fails on destroys unless a label is set.
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