aws / aws/aws-cdk-cli

(garbage-collection): add flag when running garbage collector to ignore non-authorized stacks

Open
#640 9 comments 10 reactions 1 assignee Claimed by @dgandhi62 View on GitHub
effort/small feature-request p2
Dominant language
TypeScript
Stars
105
Forks
122
Avg merge
1d 17h
Merged PRs (30d)
71

Description

### 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:///eu-west-1...
Error refreshing stacks: AccessDenied: User: arn:aws:sts:::assumed-role/ is not authorized
to perform: cloudformation:GetTemplateSummary on
resource: arn:aws:cloudformation:eu-west-1::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

- [X] 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.