[Feature Request](Stack Dependencies): stack dependency should also be hornoured during "cdk destroy" #26491
Labels
@aws-cdk/aws-lambda
Related to AWS Lambda
effort/medium
Medium work item – several days of effort
feature-request
A feature should be added or improved.
p2
Describe the feature
If users claim stacks' variables in an order that is different from Stack Dependencies via addDependency/add_dependency, "cdk destroy --all" will incur dependency-related "Delete_failed" stacks.
Use Case
Code examples in Python
app.py:
Additional restriction to trigger error if order wrong. In stack1 I am exporting an output
In stack2 and stack3, I am importing the stack1-export to create CFN-side explicit dependency
As you can see app.py stack variables are claimed in order:
Whereas, the Stack Dependency is created as
During the
cdk deploy --all
, the stack1 always to be created first then following stack2/3.However, during the
cdk destroy --all
, the only order destroy process is following is reverse order of the variables:it appears to be expected given current public
async destroy function
is coded here as:Which gives rise to error:
Proposed Solution
Update the the destroy function, to reverse the stacks order that deploy function used based on Stack Dependencies:
Other Information
Maybe also consider update the Stack Dependencies documentation with a highlighted text states that currently the "destroy" is not following the dependency but merely reverse var-declaration order in code.
Acknowledgements
CDK version used
2.88.0
Environment details (OS name and version, etc.)
Cloud9 latest
The text was updated successfully, but these errors were encountered: