-
Notifications
You must be signed in to change notification settings - Fork 4.5k
(events-targets): Wrong role used when adding multiple EventBus targets #19407
Copy link
Copy link
Closed
Labels
@aws-cdk/aws-events-targetsbugThis issue is a bug.This issue is a bug.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortin-progressThis issue is being actively worked on.This issue is being actively worked on.p1
Description
What is the problem?
When adding an EventBus target to a rule, CDK creates a role that grants PutEvents 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:
rule = events.Rule(
self,
"rule",
event_pattern=events.EventPattern(
source=["aws.ecr"],
),
)
for i in range(5):
bus = events.EventBus(self, f"bus-{i}")
rule.add_target(events_targets.EventBus(bus))
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:
| const role = this.props.role ?? singletonEventRole(rule, [this.putEventStatement()]); |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
@aws-cdk/aws-events-targetsbugThis issue is a bug.This issue is a bug.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortin-progressThis issue is being actively worked on.This issue is being actively worked on.p1