How to fix stack deletion failures caused by externally deleted resources
Last updated: September 9, 2025
If you're unable to delete a stack because a resource was deleted outside of Terraform, the deletion process may fail during the planning refresh step. This happens because Terraform is still trying to read the missing resource from its state file.
Solution: Remove the stale resource from Terraform state
To resolve this issue, you need to detach the stale resource from the Terraform state using one-off Tasks:
Identify the resource address: Run a one-off Task with
terraform state listto locate the exact address of the resource that's causing the failure.Remove the resource from state: Run another one-off Task with
terraform state rm [resource_address]to remove the problematic resource from the state file.
Why this happens
When a resource is deleted outside of Terraform (manually or through other tools), Terraform's state file still contains a reference to that resource. During the refresh step of any Terraform operation, Terraform attempts to read the current state of all resources, which fails for the deleted resource and causes the entire operation to fail.
Additional resources
For more detailed information about removing resources from Terraform state, including how to handle multiple resources, check out our comprehensive guide: Terraform State RM blog post.
Note: Adding a removed block to your Terraform configuration won't resolve this issue if the failure occurs during the planning refresh step, as Terraform needs to successfully refresh the state before it can process configuration changes.