How to Use Stack Dependencies Across Spaces
Last updated: December 12, 2024
Understanding Stack IDs
When using a spacelift_stack data source, ensure you're using the correct stack ID. You can find the correct ID by:
Checking the URL of the stack in the Spacelift GUI
Clicking the "Copy ID" button in the stack's interface
Cross-Space References
When referencing stacks across different spaces, keep in mind:
A stack can reference child spaces or the same space
A stack cannot directly reference sibling or parent spaces using data sources
Using Stack Dependencies
Stack dependencies can be used between sibling spaces, but there are important permissions to consider:
The stack creating the dependency needs at least reader permission for the dependency stack
The stack creating the dependency needs admin permission for the dependee stack
If a stack in one space is trying to create a dependency with a stack in a sibling space, it may not have the necessary permissions, resulting in a "stack not found" error.
Troubleshooting
If you encounter errors like "Error: stack not found" or "Error: could not create stack dependency", check the following:
Verify the stack ID is correct
Ensure the stack creating the dependency has the necessary permissions in both spaces
If using a stack manager, make sure it has the required access to create dependencies across spaces
Best Practices
To optimize your Spacelift setup:
Review your space structure regularly
Consider the Spacelift Spaces Best Practices guide
If you're facing complex setups, consider scheduling a session with a Spacelift Solutions Architect to review and optimize your configuration
This diagram illustrates a typical stack structure in Spacelift. Understanding this hierarchy can help in planning your stack dependencies and permissions.