How do I remove the resources a stack manages when deleting a stack via Terraform?
Last updated: July 14, 2025
Context
When using Spacelift to manage infrastructure, it's important to understand what happens to the infrastructure resources when you remove a spacelift_stack resource from your Terraform configuration. A common concern is whether removing the stack definition in Terraform will also delete the infrastructure it manages.
Answer
Removing a `spacelift_stack` resource from your Terraform configuration will not automatically destroy the infrastructure resources managed by that stack. The infrastructure resources will remain intact.
To destroy the infrastructure resources managed by a stack, you must explicitly use a `spacelift_stack_destructor` resource. This is a safety measure to prevent accidental deletion of infrastructure.
For more information about stack destructors and how to use them, please refer to the Spacelift Stack Destructor documentation.