-
Notifications
You must be signed in to change notification settings - Fork 51
feat(cli): gc can ignore user-verified unauthorized non-cdk stacks #850
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #850 +/- ##
==========================================
+ Coverage 83.23% 83.74% +0.50%
==========================================
Files 71 71
Lines 10396 10407 +11
Branches 1306 1317 +11
==========================================
+ Hits 8653 8715 +62
+ Misses 1705 1651 -54
- Partials 38 41 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also missing a readme entry. this definitely needs it because it is a very tricky property to add and without the proper documentation, users will use it incorrectly and accidentally delete important assets.
packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/garbage-collector.ts
Show resolved
Hide resolved
packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/stack-refresh.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/garbage-collector.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/garbage-collector.ts
Outdated
Show resolved
Hide resolved
packages/aws-cdk/lib/cli/cli.ts
Outdated
| createdBufferDays: args['created-buffer-days'], | ||
| bootstrapStackName: args.toolkitStackName ?? args.bootstrapStackName, | ||
| confirm: args.confirm, | ||
| ignoreStacks: args['ignore-stacks'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing a cli integ test for this to ensure that this is actually exposed via the cli. integ test should deploy 2 stacks with an asset each, one stack with a prefix, and then verify that gc with ignore stacks actually does delete the asset of the stack with prefix.
f00d0f1 to
65b3bf1
Compare
packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/garbage-collector.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
option names
…e collection - Removed old functionality on ignore-stacks & skip-unauthorized-stacks - Add --skip-unauthorized-stacks-when-noncdk CLI option to handle AccessDenied errors for non-cdk stack names entered by user - Update interfaces and constructors with new parameter
bf76d06 to
248ad08
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also definitely needs a readme update :)
packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/garbage-collector.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/garbage-collector.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/garbage-collector.ts
Show resolved
Hide resolved
packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/stack-refresh.ts
Outdated
Show resolved
Hide resolved
…CI support - Replace individual warnings with single batch prompt for unauthorized stacks - Add CDK_GC_AUTO_APPROVE_UNAUTHORIZED env var for CI/CD automation - Add CI detection to fail fast instead of hanging on user prompts - Add performance optimization with early return for empty assets
- Remove global environment variable from test setup and add it locally to test - Add CI detection in failing tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
few more comments. this one is tricky!
packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/garbage-collector.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/stack-refresh.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/stack-refresh.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/stack-refresh.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/stack-refresh.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/stack-refresh.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/toolkit-lib/lib/api/garbage-collection/stack-refresh.ts
Outdated
Show resolved
Hide resolved
…ption to --unauth-native-cfn-stacks-to-skip - Change default response from 'yes' to 'no' when prompting to skip unauthorized stacks - Rename parameter from skipUnauthorizedStacksWhenNonCdk to unauthNativeCfnStacksToSkip - Remove wrong ci/cd detection logic
Fixes #640
The gc command currently fails when encountering AccessDenied errors on non-CDK stacks during garbage collection. This PR adds a new option
--unauth-native-cfn-stacks-to-skipto handle this situation.Users can specify multiple stack names or glob patterns to skip when unauthorized access errors occur. When stacks matching the provided patterns encounter access denied errors, the command shows a confirmation prompt asking whether to skip these stacks and continue with garbage collection. The default response is 'no' to ensure users explicitly confirm the action. It remains the user's responsibility to ensure that the stacks entered are non-cdk stacks.
The 'no' default was chosen over 'yes' to prevent unintended behavior until a future
--yesflag is implemented for the cdk-cli. While a shorter alias was considered for the option name, it was rejected to avoid user confusion.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license