-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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: Destroy reports success when there is nothing to destroy #22240
Comments
The CDK has a check here to see if the stack exists, and just returns without making an API call if the stack wasn't found aws-cdk/packages/aws-cdk/lib/api/deploy-stack.ts Lines 645 to 648 in f834a45
However as you've reported, it still reports success here after the function returns without doing anything aws-cdk/packages/aws-cdk/lib/cdk-toolkit.ts Line 515 in f834a45
I think that there are a couple ways to address this and I'd like to hear what people think. I think it would be nice if the lookup occurred before it asks the user for confirmation on if they want to destroy the stack, however what might be an easier way to address this would be to throw an error or print a statement saying we couldn't find the stack specified instead of printing the success statement. I'm curious if people think that this should throw an error message if the stack couldn't be found, or if there should just be a printed statement. Personally I think throwing an error message to make it as clear as possible would be most helpful. |
It depends a lot on what you expect. Personally I would expect at the end of At least correctly printing that we didn't do anything because we didn't need to would be a good start. |
I agree, we should throw an error if the specified stack or all of the stacks are not deployed when the command is run, as there is no point destroying non-existant stacks. Can I work on this change? |
Go ahead @ishon19! |
Describe the bug
Configure AWS profile to an account that has not been bootstrapped with cdk.
Run cdk destroy - cdk reports success.
Expected Behavior
cdk should report an error indicating that the selected stack does not exist.
Current Behavior
cdk incorrectly reports success in destroying the stack.
Reproduction Steps
Create a stack, switch accounts. execute: cdk destroy
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.43.1 (build c1ebb85)
Framework Version
No response
Node.js Version
v16.16.0
OS
MacOS Monterey
Language
Typescript
Language Version
Actually, javascript but drop down does not offer that option
Other information
No response
The text was updated successfully, but these errors were encountered: