A new engineer's `terraform plan` shows 50 changes, while CI shows none for the same commit.
IntermediateTroubleshootingLost, Corrupted and Drifted State
Answer
Likely causes → Different workspace, different var files or TF_VAR_* environment variables, a different provider version (old .terraform dir with an unlocked provider), or different credentials pointing at another account.
Diagnose →
terraform workspace show; env | grep ^TF_; aws sts get-caller-identity
terraform version; cat .terraform.lock.hcl | grep -A1 'provider "registry'
Fix → Align workspace, var files and credentials; rm -rf .terraform && terraform init.
Prevent → Wrap commands in a Makefile/script that selects workspace and var file, and print account ID and workspace at the top.
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