-
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
aws-events: EventBus and EventBusPolicy only accept a single statement #24671
Comments
Hi @ctobolski , thanks for reporting this issue and sharing the code snippet. I am able to reproduce this. Currently I am marking this as P2 (which would mean it won't be worked upon immediately). We use +1s to help prioritize our work, and are happy to re-evaluate this issue based on community feedback. You can reach out to the cdk.dev community on Slack to solicit support for re-prioritization. However if you would like to contribute, here is the contributing guide to get started. |
👍🏼 |
+1 and fixing. I'll take care of this. |
@ctobolski + @khushail I opened up #27340 with a fix.
Currently, the CFN construct for an EventBusPolicy takes only a single statement. However, updating |
@jsvasquez if you have a chance to review the above I would appreciate it! |
+1 |
1 similar comment
+1 |
…27340) Enable the creation of multiple event bus policies on a single event bus. Closes #24671. The result of the Policies created by the integration test is a resource policy on the event bus that looks like ```json { "Version": "2012-10-17", "Statement": [{ "Sid": "Statement2", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::<account-id>:root" }, "Action": "events:PutRule", "Resource": "arn:aws:events:us-west-2:<account-id>:event-bus/StackBusAA0A1E4B" }, { "Sid": "Statement1", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::<account-id>:root" }, "Action": "events:PutEvents", "Resource": "arn:aws:events:us-west-2:<account-id>:event-bus/StackBusAA0A1E4B" }] } ``` ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
Describe the bug
The EventBus only accepts a single IAM statement in the policy. If I want to grant multiple principals different access to a bus, it should be possible with
addToResourcePolicy
, but that method explicitly denies additional statements. Defining anEventBusPolicy
does not alleviate the issue, becauseEventBusPolicy
also only accepts a single iam.PolicyStatement.Expected Behavior
The documentation for
EventBusPolicy
andEventBus
indicate that additional permissions should be added through theaddToResourcePolicy
method.https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_events.EventBus.html#applywbrremovalwbrpolicypolicy
https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_events.EventBusPolicy.html
Expected behavior would be that
addToResourcePolicy
creates or updates the existing resource policy with additional statements.Current Behavior
New statements are silently ignored, and the construct does not support adding additional permissions.
It looks like the behavior to only accept a single statement is codified in the
addToResourcePolicy
implementation. Shouldn't the policy contain a policy document rather than a single statement?https://github.com/aws/aws-cdk/blob/main/packages/@aws-cdk/aws-events/lib/event-bus.ts#L341
It seems odd that not having a SID would cause an error to be thrown, while not adding new permissions would allow execution to continue and potentially deploy a change that doesn't have the correct policy.
Reproduction Steps
Create a bus, add multiple resource policies
Possible Solution
Modify the
EventBusPolicy
to accept a PolicyDocument rather than a PolicyStatement, and update theaddToResourcePolicy
to append new statements to the existing policy.Additional Information/Context
No response
CDK CLI Version
2.69
Framework Version
No response
Node.js Version
v16.17.1
OS
OSX
Language
Typescript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: