Skip to content
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: add flag when running garbage collector to ignore non-authorized stacks #32322

Open
1 of 2 tasks
TiagoVentosa opened this issue Nov 28, 2024 · 3 comments
Open
1 of 2 tasks
Labels
@aws-cdk/core Related to core CDK functionality closing-soon This issue will automatically close in 4 days unless further comments are made. effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 package/tools Related to AWS CDK Tools or CLI response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@TiagoVentosa
Copy link

TiagoVentosa commented Nov 28, 2024

Describe the feature

add some kind of flag to the cdk gc command (for example --skip-unauthorized-stacks) so that when checking the stacks (GetTemplateSummary) it ignores those that the user does not have access instead of failing the command

Use Case

I was very excited for this new feature, but when I tried running it, I got the following error:

npx cdk gc --unstable=gc --rollback-buffer-days 5
 ⏳  Garbage Collecting environment aws://<ACCOUNT>/eu-west-1...
Error refreshing stacks: AccessDenied: User: arn:aws:sts::<ACCOUNT>:assumed-role/<ROLE> is not authorized 
to perform: cloudformation:GetTemplateSummary on 
resource: arn:aws:cloudformation:eu-west-1:<ACCOUNT>:stack/<ORGANIZATION-STACK> 
with an explicit deny in a service control policy

(newlines added to improve readability)

Where is a stack used my my company to do initial setup of AWS accounts.

Proposed Solution

Instead of automatically failing, have some way to ignore stacks in error. Right now I know of no way to skip it

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.171.1

Environment details (OS name and version, etc.)

macOS Sonoma 14.7

@TiagoVentosa TiagoVentosa added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Nov 28, 2024
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Nov 28, 2024
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Nov 29, 2024
@khushail khushail self-assigned this Nov 29, 2024
@khushail
Copy link
Contributor

khushail commented Nov 29, 2024

Hi @TiagoVentosa , thanks for reaching out and requesting this.
I see that cdk gc support was implemented recently with the idea of collecting unused assets in your bootstrapped S3 bucket with these PRs -

But what you are suggesting also seems to be a good add-on.

Requesting team's thoughts on this feature as it would be great to have their say whether its something on their radar for future implementation or would be considered from community.

@khushail khushail added p2 effort/small Small work item – less than a day of effort @aws-cdk/core Related to core CDK functionality and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. effort/small Small work item – less than a day of effort labels Nov 29, 2024
@khushail khushail removed their assignment Nov 29, 2024
@rix0rrr
Copy link
Contributor

rix0rrr commented Dec 2, 2024

It will be unsafe to do garbage collection in that configuration. I suppose we can add a flag, but can you add a bit more color to this story?

Why are you in a situation where you are trying to GC assets on an account that you don't have access to all stacks in?

@otaviomacedo otaviomacedo added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Dec 16, 2024
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/core Related to core CDK functionality closing-soon This issue will automatically close in 4 days unless further comments are made. effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 package/tools Related to AWS CDK Tools or CLI response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

4 participants