terraform destroy
The command that deletes every resource the current state records, in reverse dependency order.
Run against the wrong state or workspace it deletes real infrastructure and its data.
In more detail
Preview it first with terraform plan -destroy and read the count. It only removes what this configuration's state records; anything made by hand is invisible to it. Afterwards the state file still exists but is empty, and applying again rebuilds everything.
Examples
terraform plan -destroyterraform destroyRelated terms
- terraform plan — The command that compares configuration, state and reality and prints the actions needed to make them match, without changing anything.
- prevent_destroy — A lifecycle setting that makes any plan fail if it would destroy that resource, including as part of a replacement.
- teardown — Removing or releasing everything that was set up for a piece of work, from a test's open connections to a whole temporary environment, once it is no longer needed.
- dependency graph — Terraform's internal map of every resource, data source and value in a configuration, linked by which depends on which.
Taught in
- What Is Infrastructure As Code? — Infrastructure as Code with Terraform
- Installing Terraform And Meeting The CLI — Infrastructure as Code with Terraform
- Tearing It Down With Destroy — Infrastructure as Code with Terraform
- The Plan That Wanted To Destroy Production — HashiCorp Terraform Associate (004) Exam Prep
- One Hour, No Weights Published — HashiCorp Terraform Associate (004) Exam Prep
- Infrastructure As Code, And One Workflow For Every Platform — HashiCorp Terraform Associate (004) Exam Prep
- Providers: How Terraform Reaches Every API — HashiCorp Terraform Associate (004) Exam Prep
- Versions, The Lock File And Provider Aliases — HashiCorp Terraform Associate (004) Exam Prep
- State: Terraform's Memory Of What It Built — HashiCorp Terraform Associate (004) Exam Prep
- Write, Plan, Apply, And What Init Prepares — HashiCorp Terraform Associate (004) Exam Prep
- Reading A Plan, Saving It, Applying It — HashiCorp Terraform Associate (004) Exam Prep