Synopsis
Destroy previously-created infrastructureDescription
Theterraform destroy command is a convenient way to destroy all remote objects managed by a particular Terraform configuration.
This command is a convenience alias for:
terraform destroy to conveniently clean up all of those temporary objects once you are finished with them.
Usage
Options
Approval Options
Skip interactive approval of the destroy plan before destroying.
Ask for input for variables if not directly set.
Targeting Options
Limit the destroy operation to only the given module, resource, or resource instance and all of its dependencies. You can use this option multiple times to include more than one object. This is for exceptional use only.
Variable Options
Set a value for one of the input variables in the root module of the configuration. Use this option more than once to set more than one variable. Format:
-var 'name=value'Load variable values from the given file, in addition to the default files
terraform.tfvars and *.auto.tfvars. Use this option more than once to include more than one variables file.State Management
Don’t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.
Duration to retry a state lock. For example: ”10s” for 10 seconds.
Path to read and save state (unless state-out is specified). Defaults to “terraform.tfstate”. Legacy option for the local backend only.
Path to write state to that is different than “-state”. This can be used to preserve the old state. Legacy option for the local backend only.
Path to backup the existing state file before modifying. Defaults to the “-state-out” path with “.backup” extension. Set to ”-” to disable backup.
Performance Options
Limit the number of parallel resource operations.
Update the state prior to checking for differences. Set to false to skip refreshing.
Output Options
If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.
Produce output in a machine-readable JSON format. When using this flag, you must also specify
-auto-approve.If specified, output won’t contain any color.
Examples
Basic Destroy
Destroy all resources with interactive approval:Auto-Approve Destroy
Destroy all resources without interactive approval:Destroy Specific Resources
Destroy only specific resources:Destroy with Variables
Destroy with variable values:Multiple Targets
Destroy multiple specific resources:Exit Codes
0- Success1- Error occurred
Important Notes
This command also accepts many of the plan-customization options accepted by the
terraform plan command. For more information on those options, run: