Terraform Destroy

Learn to destroy the created Terraform modules.


As we know, we can delete Terraform file resources by using rm -rf.

This is fine for simple resources managed within a local directory since the Terraform state file, Terraform module, and the file under Terraform’s control are all in one place. Blitzing them all makes a clean break.

This approach is less viable, however, when we come to manage resources remotely, such as cloud service instances. We can’t manually destroy an EC2 (virtual machine) instance on AWS without getting an inconsistent Terraform state file on our local host. The state file will think the EC2 instance still exists even though we’ve destroyed it manually.

What we want is a simple way to remove the resources under Terraform’s control so that the real world view and the Terraform view are consistent.

Get hands-on with 1200+ tech skills courses.