Skill 3.6.1
terraform destroy and destroy plans
Key Concepts
terraform destroy is an alias for terraform apply -destroy. It plans the destruction of every resource in state, shows the plan and asks for confirmation. Objects are destroyed in reverse dependency order, so a server is removed before the network it uses. terraform plan -destroy previews the destruction without changing anything and can be saved with -out for review.
Destroy affects only objects in state: resources created outside Terraform, and data sources, which Terraform only reads, are untouched. Resources with lifecycle { prevent_destroy = true } make the destroy plan fail, which protects critical resources such as production databases.