terraform destroy command
Theterraform destroy command deprovisions all objects managed by a Terraform configuration.
While you will typically not want to destroy long-lived objects in a productionenvironment, Terraform is sometimes used to manage ephemeral infrastructurefor development purposes, in which case you can useterraform destroy toconveniently clean up all of those temporary objects once you are finishedwith your work.
Usage
Usage:terraform destroy [options]
This command is just a convenience alias for the following command:
terraform apply -destroyFor that reason, this command accepts most of the options thatterraform apply accepts, although it doesnot 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 ofdestroying would be, by running the following command:
terraform plan -destroyThis will runterraform plan indestroy mode, showingyou the proposed destroy changes without executing them.
Note: The-destroy option toterraform apply exists only inTerraform v0.15.2 and later. For earlier versions, youmust useterraform destroy to get the effect ofterraform apply -destroy.
Target a specific resource
You can use the-target option to destroy a particular resource and its dependencies. For example, if your Terraform configuration contained aaws_instance resource with the labelexample, you could destroy that resource with the following command.
terraform destroy -target aws_instance.example