Destroy a Stack
This guide explains how to destroy a Stack in HCP Terraform.
We recommend destroying a Stack in phases to ensure HCP Terraform destroys your infrastructure safely. First, destroy your Stack deployment’s infrastructure, then the deployments themselves, and then the Stack itself.
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 deployment infrastructure
Begin by navigating to the Stack you want to interact with:
- In the navigation menu, click Projects under Manage.
- Select the project containing your Stack.
- Click Stacks in the navigation menu.
- Select the Stack you want to destroy the resources of.
Before destroying a deployment, we recommend removing the resources that the deployment manages. Otherwise, the infrastructure managed by your Stack’s deployments will continue without destruction, and you will have to clean them up manually.
For each deployment you intend to destroy, perform the following steps:
- Click on the name of the deployment you want to delete.
- Select Destruction and Deletion from the sidebar navigation.
- Under Destroy infrastructure, click Create destroy plan to queue a destroy plan.
- HCP Terraform redirects you to the plan page, where a plan with the trigger “Destroy plan requested” awaits your approval.
- Approve the destroy plan HCP Terraform generates.
HCP Terraform then destroys the resources for your Stack deployment.
Delete a deployment
After deleting a deployment’s infrastructure, you can delete that deployment. For each deployment you intend to destroy, perform the following steps:
- Click on the name of the deployment you want to delete.
- Select Destruction and Deletion from the sidebar navigation.
- Under Delete deployment, click Delete deployment <deployment_name> from <stack_name>.
You can also destroy a deployment directly from your tfdeploy.hcl
file by performing the following steps:
- Remove a
deployment
block from your deployment configuration file and commit the change. - HCP Terraform automatically detects the change and fetches the new configuration version.
- Select Plans from your stack’s sidebar menu, then select the plan HCP Terraform generated with the trigger, Deployment removed from configuration.
- Approve the plan.
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 your deployment's infrastructure and then deleting all of that Stack’s deployments. Once your Stack contains no deployments, you can delete a Stack by performing the following steps:
- Navigate to the Stack's main page.
- Select Stack settings in the navigation menu.
- Select Destruction and Deletion in the navigation menu.
- 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.