Skip to content

fix(events-targets): EventBus IAM statements are only added for the first target#20479

Merged
mergify[bot] merged 5 commits intoaws:masterfrom
comcalvi:event-bus
Jun 1, 2022
Merged

fix(events-targets): EventBus IAM statements are only added for the first target#20479
mergify[bot] merged 5 commits intoaws:masterfrom
comcalvi:event-bus

Conversation

@comcalvi
Copy link
Copy Markdown
Contributor

@comcalvi comcalvi commented May 24, 2022

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

@comcalvi comcalvi requested a review from rix0rrr May 24, 2022 21:12
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label May 24, 2022
@gitpod-io
Copy link
Copy Markdown

gitpod-io bot commented May 24, 2022

@github-actions github-actions bot added bug This issue is a bug. effort/small Small work item – less than a day of effort p1 labels May 24, 2022
@aws-cdk-automation aws-cdk-automation requested a review from a team May 24, 2022 21:13
this.props.role.addToPrincipalPolicy(this.putEventStatement());
}
const role = this.props.role ?? singletonEventRole(rule, [this.putEventStatement()]);
const role = this.props.role ?? singletonEventRole(rule, []);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should change the implementation of singletonEventRole to not take any statements to prevent this from happening in the future.

@rix0rrr rix0rrr changed the title fix(events-targets): Adding targets correctly adds them to the singleton policy fix(events-targets): IAM statements are only added for the first target Jun 1, 2022
@rix0rrr rix0rrr changed the title fix(events-targets): IAM statements are only added for the first target fix(events-targets): EventBus IAM statements are only added for the first target Jun 1, 2022
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Jun 1, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 2f503bb
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 74318c7 into aws:master Jun 1, 2022
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Jun 1, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug This issue is a bug. contribution/core This is a PR that came from AWS. effort/small Small work item – less than a day of effort p1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(events-targets): Wrong role used when adding multiple EventBus targets

4 participants