Is it possible to create a destruction plan for a workspace in Terraform Cloud?
It is, yes.
- You can run
terraform destroy on the command line using the remote backend.
- You can also manually queue up a destroy plan in the Terraform Cloud UI in workspace Settings -> Destruction and Deletion:
Note that in both of these cases, with Terraform Cloud you must also have “Allow destroy plans” toggled (this is on by default, but allows administrators to prevent complete destruction of infrastructure without configuration changes)
More importantly though:
When marking a resource
prevent_destroy = true I would [expect]
terraform destroy to destroy everything not related to this resource.
This is not how
prevent_destroy works, sadly - if you have resources with this on, any destroy plan will fail. See the documentation on this feature; note this is not specific to Terraform Cloud, this is a regular OSS feature in Terraform CLI.
I want to destroy only specific components but I can’t find a way to set up the plan.
To do this, you would remove the configuration for the component in question and run
terraform apply. Terraform will create a plan to destroy the component you removed. You’re declaring that you no longer want that component to exist in your infrastructure by removing it from your configuration.