Unintended terraform destroy — infrastructure wiped
terraform destroy shows all resources will be destroyed
Focused incident mode — strips away everything but this runbook.
Symptoms
- terraform destroy shows all resources will be destroyed
- Production infrastructure disappeared after running terraform destroy
- Terraform plan now shows everything as new (state wiped)
Never run terraform destroy in production without explicit approval. Use -target for surgical destruction only.
Evidence to grab
Collect these artifacts before you change anything — they prove (or rule out) each cause.
Destroy plan output
terraform plan -destroy 2>&1 | tail -10Cloud console showing deleted resources
aws ec2 describe-instances --query 'Reservations[].Instances[].InstanceId'
Diagnostic flow
Run the steps in order, marking each claim confirmed or refuted. The evidence you gather feeds the ranked causes below.
Guided decision tree is ready.
Steps with commands, expected output, and pass/fail branches.
Ranked root causes
Evidence checklist
- CI pipeline ran terraform destroy instead of terraform apply
- All resources destroyed at once
Confirm before fixing
terraform state listCheck state after destroy
Fix
terraform import <RESOURCE-ADDR> <CLOUD-ID>Import critical resources back
Resolution runbook
Apply from top to bottom after the cause is confirmed. Review every command before running it — risk tags are shown on each.
terraform state list | wc -lAssess the scope of the damage
aws ec2 describe-instances --query 'Reservations[].Instances[].InstanceId' --output textCheck what still exists in the cloud
terraform import <RESOURCE-ADDR> <CLOUD-ID>Begin importing resources back into state
terraform planVerify state matches infrastructure
Prevention
- Require manual approval for terraform destroy in CI pipelines.
- Use -target when destroying specific resources.
- Set prevent_destroy lifecycle on critical resources.
- Keep regular state backups and test the restore process.
Related runbooks
Same stack, same failure family — worth a skim.
terraform plan shows - destroy for resources that should exist
terraform plan shows everything will be created (no existing resources in state)
terraform plan shows - destroy for a resource that is still live
Commands marked READ CHANGE DESTRUCTIVE — never run DESTRUCTIVE commands against production data you cannot restore. Copy → verify → execute.