-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cdk cli: Deploy of empty non-toplevel stack does not get deleted #20822
Comments
@rabbittsoup, thanks for pointing the possible suspect, I tested locally and prepared the PR, stack.stackName must be actually stack.hierarchicalId. |
Fixed selector pattern for the empty stack which must be deleted during the deployment. I set stack selector pattern as `stack.hierarchicalId` because hierarchicalId is used in `selectMatchingStacks` method which is called when destroy logic is looking for the stack to be deleted. https://github.com/aws/aws-cdk/blob/92d6d58029595735df6902db5f820b1182dfb27b/packages/aws-cdk/lib/api/cxapp/cloud-assembly.ts#L138 There is also existing integration test which covers destroy logic and it works now without additional modifications: https://github.com/aws/aws-cdk/blob/92d6d58029595735df6902db5f820b1182dfb27b/packages/aws-cdk/test/integ/cli/cli.integtest.ts#L685 **How I tested it locally?** - Prepared a package with fix with `yarn package` and installed with `npm install -g dist/js/aws-cdk-0.0.0.tgz` - Reproduced steps from the bug #20822 - Ensured that the issue is fixed closes #20822 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
Fixed selector pattern for the empty stack which must be deleted during the deployment. I set stack selector pattern as `stack.hierarchicalId` because hierarchicalId is used in `selectMatchingStacks` method which is called when destroy logic is looking for the stack to be deleted. https://github.com/aws/aws-cdk/blob/92d6d58029595735df6902db5f820b1182dfb27b/packages/aws-cdk/lib/api/cxapp/cloud-assembly.ts#L138 There is also existing integration test which covers destroy logic and it works now without additional modifications: https://github.com/aws/aws-cdk/blob/92d6d58029595735df6902db5f820b1182dfb27b/packages/aws-cdk/test/integ/cli/cli.integtest.ts#L685 **How I tested it locally?** - Prepared a package with fix with `yarn package` and installed with `npm install -g dist/js/aws-cdk-0.0.0.tgz` - Reproduced steps from the bug aws#20822 - Ensured that the issue is fixed closes aws#20822 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Describe the bug
After deploying a stack that uses a stage as it's scope (and not the App), so that it is not defined at the top level of the construct tree, a subsequent deploy of that same stack with all resources removed (including analytics_reporting=False) will recognize the stack as empty and existing, but does not delete it.
Expected Behavior
A previously existing stack deployed with no resources should delete the stack.
Current Behavior
The previously existing stack is not deleted.
Reproduction Steps
cdk deploy '**'
cdk deploy '**'
Possible Solution
I suspect the stack.stackName reference during the deploy of an existing empty stack should be stack.node.path instead.
aws-cdk/packages/aws-cdk/lib/cdk-toolkit.ts
Line 173 in fb5ebdd
Additional Information/Context
No response
CDK CLI Version
2.28.1 (build d035432)
Framework Version
2.28.1
Node.js Version
14.16.0
OS
AL2
Language
Python
Language Version
Python 3.8
Other information
No response
The text was updated successfully, but these errors were encountered: