Destroy Terraform-managed Infrastructure

Learn how to delete an infrastructure managed by Terraform.

Purpose of the terraform destroy command

Destroying what we deployed seems counterintuitive, but there are many cases where it might be useful. We might be deploying development environments for a project and want to clean up the resources when the project concludes. We might be building an environment for testing in a CI/CD pipeline and want to tear down the environment when the tests are complete. The terraform destroy command is used to destroy Terraform-managed infrastructure.

The terraform destroy command is a powerful command. It deletes all resources under management by Terraform. This action can’t be undone. For that reason, Terraform presents an execution plan for all resources that’ll be destroyed and prompts us to confirm before performing the destroy operation.

Get hands-on with 1200+ tech skills courses.