Terraform
Destroy a Stack
We recommend destroying a Stack in phases to ensure HCP Terraform destroys your infrastructure safely. Destroy your Stack deployments before destroying the Stack itself to ensure you do not leave any unmanaged infrastructure behind.
Requirements
To destroy a Stack and delete or destroy a deployment in HCP Terraform, you must also be a member of a team with one of the following permissions:
Delete deployments
Before destroying a Stack, we recommend destroying your deployments to remove the resources that those deployments manage. Otherwise, the infrastructure managed by your Stack’s deployments can continue without destruction, and you will have to clean them up manually.
To destroy a deployment’s infrastructure, add the destroy
argument to every deployment
block in your deployment configuration file. The following example destroys the production
deployment using the destroy
argument:
deployments.tfdeploy.hcl
deployment "production" {
inputs = {
region = "us-west-2"
instances = 2
}
destroy = true
}
After uploading the updated deployment configuration file and approving the subsequent plan, HCP Terraform destroys any infrastructure for the production
deployment.
After deleting all of a Stack's deployments, you can safely delete that Stack.
Delete a Stack
Before destroying a Stack in HCP Terraform, we strongly recommend deleting all of that Stack’s deployments. Once your Stack contains no deployments, you can delete a Stack by performing the following steps:
Begin by navigating to the Stack you want to interact with:
- Sign in to HCP Terraform, and select the organization that contains your Stack.
- In the navigation menu, click Projects under Manage.
- Select the project containing your Stack.
- Select Settings in the navigation menu.
- Select Destruction and Deletion.
- Click Delete stack <STACK_NAME>.
- Enter
delete
in the confirmation modal, then click Delete Stack.
By following the steps above, you can forcefully delete a Stack without removing its deployments first. However, your Stack’s deletion does not affect Stack’s resources, so they continue without management, and you have to clean them up manually.