How to delete multiple stacks with dependencies
Last updated: September 15, 2025
Currently, there is no bulk-delete feature for stacks in Spacelift. When deleting multiple stacks that have dependencies, you must delete them one at a time in reverse dependency order to ensure resources, state, and VCS links are cleaned up correctly.
Safe deletion process
Always delete stacks in reverse dependency order - this means deleting dependent stacks first, then their dependencies. This approach ensures proper cleanup of resources and maintains data integrity.
Methods for deleting multiple stacks
You can choose from the following approaches:
API approach
Use the Spacelift API to:
Create a dependency-ordered list of your stacks
Iterate over this list in reverse order
Call the stack-delete GraphQL mutation for each stack
Terraform approach
Use the Terraform method with the following steps:
Use the
spacelift_stack_destructorresource for resource teardownChain destructors with
depends_onto enforce proper deletion orderRemove the stacks after resources are torn down
Future improvements
Spacelift is tracking a feature request to manage multiple stacks as a collection, which would include group lifecycle operations (creation, update, and deletion) with automatic dependency awareness. You can upvote this feature request here.
For more information about stack dependencies and deletion, see the stack dependencies documentation.