Terraform destroy is a command that allows you to destroy either a full stack (based on your TF files), or single resources, using the -target option. You can even do:
$ terraform state list
$ terraform destroy -target RESOURCE_TYPE.NAME
$ terraform destroy -target RESOURCE_TYPE.NAME -target RESOURCE_TYPE2.NAME
$ terraform state list
Option of skipping a resource while destroying terraform resources?
$ terraform state list
$ terraform destroy -target=RESOURCE_TYPE.NAME -target=RESOURCE_TYPE2.NAME
$ terraform state list
How to remove single resources, single instances of a resource, entire modules, and more items from the Terraform state?
# Remove a Resource
$ terraform state rm module.foo.packet_device.worker[0]
# Remove a Module
$ terraform state rm module.foo
How to delete all resources except one?
# list all resources
terraform state list
# remove that resource you don't want to destroy
# you can add more to be excluded if required
terraform state rm <resource_to_be_deleted>
# destroy the whole stack except above resource(s)
terraform destroy










I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND