-
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
s3 bucket notifications creates IAM policy that has no resource boundary #5925
Comments
From an initial investigation, it seems that the Relevant code starts here: https://github.com/aws/aws-cdk/blob/master/packages/@aws-cdk/aws-s3/lib/notifications-resource/notifications-resource.ts#L52 We should explore an option to either incrementally update the permissions of this policy, or create a separate policy for each bucket. |
I ran into this issue today as well! I'm working within an enterprise environment where IAM roles must follow a naming convention and have a permissions boundary attached. I've been getting around this by using CDK Escape Hatches, but the issue with this BucketNotificationsHandler construct is that it's a top level resource, so I can't access it from either the Lambda or the S3 Bucket resources. For example:
generates a BucketNotificationsHandler with path: I got around this by going to the Root Node and doing some string filtering, like:
For me, the primary issue is that |
Thats pretty the way as of now. You could simplify a little by using the well known notification handler id: const bucketNotificationsHandler = Stack.of(this).node.tryFindChild('BucketNotificationsHandler050a0587b7544547bf325f094a3db834')! But that's not a WHOLE lot better...actually for your use-cases, I would recommend having a look at Escape hatches are mainly for pin point mutations to the underlying CloudFormation resource properties. |
BackgroundIt looks like the following open issues are all suffering from the same constraint: Many started with ProblemI cannot speak for everyone, but i believe the key call out here is the inability to use event notifications in environments where IAM access is not available (typically enterprise). Desired SolutionIn short, I believe each of the attached issues require the ability to override the IAM Role utilized by the BucketNotificationsHandler. WorkaroundThis worked enough (Python), but is far from desirable and has yet to pass review from the client. Thanks to @iliapolo for pointing out the well known notification handler id!
Cheers! ResourcesConstruct Node |
This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
you don't need to do all these magics. you just need to have (or Create) your boundary first Step 1
OR
Step2Then apply the boundary to all Roles in a stack
|
Problem Workaround in TypeScript
|
My suggested solution is just add the permission where the singleton is instantiated. We already have another permission being added here, might as well have both permissions added in one place only. I'm happy to make a PR with this change, if there's no objection. |
This restricts them to resources only the buckets that is required. To ensure permissions don't get too large minize is also enabled on the policy. Closes aws#5925
This restricts them to resources only the buckets that is required. To ensure permissions don't get too large minmize is also enabled on the policy. Closes aws#5925
I have created a PR for it: #27274 I would appreciate if it could be reviewed. |
This restricts them to resources only the buckets that is required. To ensure permissions don't get too large minmize is also enabled on the policy. Closes aws#5925
Forked off from #2781, specifically this comment
S3 bucket notifications creates an IAM role holding a policy that contains no resource boundary, specifically
"Resource": "*"
.Companies typically enforce that all IAM policies should be well bounded in their actions and resource.
https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-s3-notifications/test/integ.notifications.expected.json#L188-L208
The text was updated successfully, but these errors were encountered: