Destroy a Stack
We recommend destroying a Stack in phases to ensure HCP Terraform destroys your infrastructure safely. Delete your Stack deployments before deleting the Stack itself to ensure you do not leave any unmanaged infrastructure behind.
Requirements
You must be a member of a team with one of the following permissions:
Stack recovery requirements
You can recover a Stack that has been deleted within 30 days from the date and time it was deleted. You must meet the following requirements to recover a Stack:
- Allow deleted workspaces and stacks to be recoverable must be enabled for your organization.
- You must have a paid subscription. Refer to the pricing page for more information.
Delete Stack deployments
You can delete Stack deployments through the HCP Terraform UI or deployment configuration file.
- Sign in to HCP Terraform or Terraform Enterprise and navigate to the Stack you want to delete.
- In the page header, click New configuration. The Roll out a new configuration modal appears.
- Select Tear down Stack from the Configuration type dropdown.
- Enter
teardownin the confirmation input, then click Start.
After deleting all Stack deployments, you can safely delete the Stack.
Delete a Stack
Before deleting 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:
- Sign in to HCP Terraform or Terraform Enterprise and navigate to the Stack you want to delete.
- Select Settings in the navigation menu.
- Select Destruction and Deletion.
- Click Delete stack <STACK_NAME>.
- Enter
deletein 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 its resources, so they continue without management, and you have to clean them up manually.
Recover a Stack
You have 30 days to recover a discarded Stack. During the recovery window, HCP Terraform continues to record new configuration versions committed through VCS webhooks, but commits don’t trigger new runs. You can’t recover a Stack that has the same name as an existing Stack.
Complete the following steps to recover a discarded Stack:
- Sign in to HCP Terraform or Terraform Enterprise and navigate to the organization that contained the Stack.
- Click Settings in the sidebar, then click Recoverable items.
- For the Stack you want to recover, click the Actions dropdown and choose Recover.
- When prompted, click Recover. HCP Terraform recovers the Stack to its last known state before deletion.