Skip to content

How to Delete all Resources Except One in Terraform

If you need to delete all resources created by Terraform, except for a single, specific one, then you can do the following:

Step 1 – Get the current state list

terraform state list
Code language: Bash (bash)

Step 2 – Remove the exception resource

Remove the specific resource that you don’t want Terraform to track anymore.

terraform state rm <resource_to_be_removed>
Code language: Bash (bash)

Step 3 – Destroy the resources

terraform destroy
Code language: Bash (bash)

See also  [Solved] Instance Profile already exists in Terraform
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x