Interview Prep/Terraform/Partial Applies, Version Mismatches and CI Failures

`terraform destroy` in an ephemeral PR environment leaves resources behind and the cleanup job reports success.

AdvancedTroubleshootingPartial Applies, Version Mismatches and CI Failures
Answer

Likely causes → The destroy job ran with a different workspace/backend key (so state was empty: No changes. No objects need to be destroyed.), or resources created outside Terraform (controllers, Lambda ENIs, log groups auto-created by services).

Diagnose → Check the destroy log for 0 destroyed; find leftovers by tag:

aws resourcegroupstaggingapi get-resources --tag-filters Key=pr,Values=412

Fix → Rerun destroy with the correct workspace/key, then delete untracked leftovers.

Prevent → Fail the cleanup job if it destroys 0 resources when state is expected; tag everything with pr=<number>; manage auto-created log groups explicitly in Terraform.

All Terraform questions

More on Partial Applies, Version Mismatches and CI Failures