mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-04-10 03:01:56 -04:00
It's been a long time since we gave this page an overhaul, and with our ongoing efforts to make plan and apply incorporate all of the side-effects that might need to be done against a configuration it seems like a good time for some restructuring in that vein. The starting idea here is to formally split the many "terraform plan" options into a few different categories: - Planning modes - Planning options - Other options The planning modes and options are the subset that are also accepted by "terraform apply" when it's running in its default mode of generating a plan and then prompting for interactive approval of it. This then allows us to avoid duplicating all of that information on the "terraform apply" page, and thus allows us to spend more words discussing each of them. This set of docs is intended as a fresh start into which we'll be able to more surgically add in the information about -refresh-only and -replace=... once we have those implemented. Consequently there are some parts of this which may seem a little overwraught for what it's currently describing; that's a result of my having prepared this by just deleting the -refresh-only and -replace=... content from our initial docs draft and submitted the result, in anticipation of re-adding the parts I've deleted here in the very near future in other commits.
49 lines
1.5 KiB
Markdown
49 lines
1.5 KiB
Markdown
---
|
|
layout: "docs"
|
|
page_title: "Command: destroy"
|
|
sidebar_current: "docs-commands-destroy"
|
|
description: |-
|
|
The `terraform destroy` command is a convenient way to destroy all objects
|
|
managed by a particular Terraform configuration.
|
|
---
|
|
|
|
# Command: destroy
|
|
|
|
The `terraform destroy` command is a convenient way to destroy all remote
|
|
objects managed by a particular Terraform configuration.
|
|
|
|
While you will typically not want to destroy long-lived objects in a production
|
|
environment, Terraform is sometimes used to manage ephemeral infrastructure
|
|
for development purposes, in which case you can use `terraform destroy` to
|
|
conveniently clean up all of those temporary objects once you are finished
|
|
with your work.
|
|
|
|
## Usage
|
|
|
|
Usage: `terraform destroy [options]`
|
|
|
|
This command is just a convenience alias for the following command:
|
|
|
|
```
|
|
terraform apply -destroy
|
|
```
|
|
|
|
For that reason, this command accepts most of the options that
|
|
[`terraform apply`](./apply.html) accepts, although it does
|
|
not accept a plan file argument and forces the selection of the "destroy"
|
|
planning mode.
|
|
|
|
You can also create a speculative destroy plan, to see what the effect of
|
|
destroying would be, by running the following command:
|
|
|
|
```
|
|
terraform plan -destroy
|
|
```
|
|
|
|
This will run [`terraform plan`](./plan.html) in _destroy_ mode, showing
|
|
you the proposed destroy changes without executing them.
|
|
|
|
-> **Note:** The `-destroy` option to `terraform apply` exists only in
|
|
Terraform v1.0 and later. For earlier versions, you _must_ use
|
|
`terraform destroy` to get the effect of `terraform apply -destroy`.
|