-
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
(events-targets): Wrong role used when adding multiple EventBus targets #19407
Comments
Okay, here's the issue: If the rule already has an eventbus target with an auto-generated role, it just returns it without adding the policy statement. If I understand this correctly, the if statement should only decide whether to create the role, and should still add the statement even if it exists. |
Actually, why does the role need to be a singleton at all? Wouldn't using separate roles for each target make more sense? |
…irst target (#20479) If the `EventBus` constructor is called with no arguments, then attaching more than a single target to its policy will silently fail to add them. This is because of a strange edge case in the implementation that was not accounted for previously; it is possible for `props.role` to be `undefined`, yet `singletonEventRole()` is still capable of finding the desired role. `singletonEventRole()` does not add the new statements to any IAM policies that it finds, so as a result adding multiple targets does not add any of them. Fixes #19407. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
What is the problem?
When adding an
EventBus
target to a rule, CDK creates a role that grantsPutEvents
on the event bus. If we add multiple event buses this way, they will all share a single role that only grant access to the first event bus that we pass.Reproduction Steps
Consider the following code:
The rule will use a role that only has access to
bus-0
, and it will use this role for all targets.What did you expect to happen?
Each target uses a different role with proper access.
What actually happened?
All targets share a role that only grant access to a single target.
CDK CLI Version
2.16
Framework Version
2.16
Node.js Version
17.7.1
OS
MacOS
Language
Typescript, Python
Language Version
No response
Other information
I understand the issue may be here:
aws-cdk/packages/@aws-cdk/aws-events-targets/lib/event-bus.ts
Line 42 in e63a03d
The text was updated successfully, but these errors were encountered: