-
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
CLI: stack name is not checked before delete confirmation #32545
Comments
Hi @mrgum , thanks for reporting this. Yes, I can confirm that while deleting the deployed stack with command Current situation - the below mentioned stack does not exist yet the
while deleting the one which exists -
Looking at the code for IMO, it might include a region wide search in case , This would be good to have feature. Marking it as P3 to keep it open for community contribution. Requesting community upvotes to get the proper traction. |
I don't know how I feel about $ aws cloudformation create-stack --stack-name TestStack --template-body file://template.json
$ cdk init --language=typescript
$ cdk destroy TestStack
Are you sure you want to delete: TestStack (y/n)? y
TestStack: destroying... [1/1]
✅ TestStack: destroyed More than the ability to lookup valid stacks for a given region, I think it would be better to evaluate the list of stacks in the current app and give a warning that they might not belong to this application before the confirmation. I understand that there might be legitimate cases where you would want to |
@nmussy , I agree with you , deleting stacks outside the scope might pose a bigger risk, rather than checking stacks created in current directory/app sounds better. |
Apparently, the revert of the above PR was due to a cause unrelated to that PR. That has been corrected in this PR (see: https://github.com/aws/aws-cdk/blob/v2.173.1/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts#L286-L291). |
### Issue # (if applicable) Closes #32545. Fixes #27179. ### Reason for this change Once this [PR](#27921) was reverted by other cli-integ test regression. - revert PR: #29577 - the test for regression: https://github.com/aws/aws-cdk/blob/07ce8ecc42782475d099b89944571375341c28d3/packages/%40aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts#L190 But the regression was apparently due to a cause unrelated to that PR. That has been corrected in [this PR](#31107) (see: https://github.com/aws/aws-cdk/blob/v2.173.1/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts#L286-L291). Therefore, I submit the same PR again. ### Description of changes This PR for cli is to warn if stacks with wrong cases (=not exist) specified in `cdk destroy`. \* It does not display the message `Are you sure you want to delete:` if there is no matching stack. \* Even if the stack does not exist, `cdk destroy` will not fail, it will just print a warning. Actual Outputs: ![cdk-destroy-warn](https://github.com/user-attachments/assets/c0d70037-c863-4c78-bc22-8b51264393ac) ### Describe any new or updated permissions being added <!— What new or updated IAM permissions are needed to support the changes being introduced ? --> Nothing. ### Description of how you validated changes Both of unit tests and cli-integ tests. The changes were already approved in the last PR. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Comments on closed issues and PRs are hard for our team to see. |
### Issue # (if applicable) Closes #32545. Fixes #27179. ### Reason for this change Once this [PR](#27921) was reverted by other cli-integ test regression. - revert PR: #29577 - the test for regression: https://github.com/aws/aws-cdk/blob/07ce8ecc42782475d099b89944571375341c28d3/packages/%40aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts#L190 But the regression was apparently due to a cause unrelated to that PR. That has been corrected in [this PR](#31107) (see: https://github.com/aws/aws-cdk/blob/v2.173.1/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts#L286-L291). Therefore, I submit the same PR again. ### Description of changes This PR for cli is to warn if stacks with wrong cases (=not exist) specified in `cdk destroy`. \* It does not display the message `Are you sure you want to delete:` if there is no matching stack. \* Even if the stack does not exist, `cdk destroy` will not fail, it will just print a warning. Actual Outputs: ![cdk-destroy-warn](https://github.com/user-attachments/assets/c0d70037-c863-4c78-bc22-8b51264393ac) ### Describe any new or updated permissions being added <!— What new or updated IAM permissions are needed to support the changes being introduced ? --> Nothing. ### Description of how you validated changes Both of unit tests and cli-integ tests. The changes were already approved in the last PR. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.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
if you cdk destroy a stack that does not exist (say you are accidentally in the directory) cdk says
Are you sure you want to delete: (y/n)?
and does nothing when you say y
Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
cdk to respond
No stacks match the name(s) whatever/you/asked/for
like cdk synth does
Current Behavior
Are you sure you want to delete: (y/n)?
Reproduction Steps
cdk destroy made/of/a/nonexistent/stack
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.173.1 (build 4eac959)
Framework Version
No response
Node.js Version
v22.11.0
OS
Mac
Language
Python
Language Version
3.13
Other information
I don't think the language is relevant
The text was updated successfully, but these errors were encountered: