HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

terraform destroy — Destroy all objects managed by a Terraform configuration. More information: <https://developer.hashi

Submitted by: @import:tldr-pages··
0
Viewed 0 times
commandalldestroyterraformcliobjectsterraform destroymanaged

Problem

How to use the terraform destroy command: Destroy all objects managed by a Terraform configuration. More information: <https://developer.hashicorp.com/terraform/cli/commands/destroy>.

Solution

terraform destroy — Destroy all objects managed by a Terraform configuration. More information: <https://developer.hashicorp.com/terraform/cli/commands/destroy>.

Destroy all infrastructure in the current directory:
terraform destroy


Destroy infrastructure, skipping interactive approval:
terraform destroy -auto-approve


Destroy a specific resource:
terraform destroy -target {{resource_type.resource_name[instance_index]}}


Specify values for input variables:
terraform destroy -var '{{name1}}={{value1}}' -var '{{name2}}={{value2}}'


Specify values for input variables from a file:
terraform destroy -var-file {{path/to/file.tfvars}}


Destroy infrastructure with compact warnings:
terraform destroy -compact-warnings

Code Snippets

Destroy all infrastructure in the current directory

terraform destroy

Destroy infrastructure, skipping interactive approval

terraform destroy -auto-approve

Destroy a specific resource

terraform destroy -target {{resource_type.resource_name[instance_index]}}

Specify values for input variables

terraform destroy -var '{{name1}}={{value1}}' -var '{{name2}}={{value2}}'

Specify values for input variables from a file

terraform destroy -var-file {{path/to/file.tfvars}}

Context

tldr-pages: common/terraform destroy

Revisions (0)

No revisions yet.