Skip to content

Commit

Permalink
fix(events): cannot have more than one cross-account Rule (#19441)
Browse files Browse the repository at this point in the history
Fixes #12479, Resolves #12538

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
cgarvis committed Mar 18, 2022
1 parent c94c277 commit a257846
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-events/lib/rule.ts
Expand Up @@ -397,7 +397,7 @@ export class Rule extends Resource implements IRule {
});
new CfnEventBusPolicy(eventBusPolicyStack, 'GivePermToOtherAccount', {
action: 'events:PutEvents',
statementId: `Allow-account-${sourceAccount}`,
statementId: `Allow-account-${sourceAccount}-${this.node.addr}`,
principal: sourceAccount,
});
}
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-events/test/rule.test.ts
Expand Up @@ -901,6 +901,7 @@ describe('rule', () => {
const app = new cdk.App();

const sourceAccount = '123456789012';
const nodeAddr = 'c810f4680339b01edf1f157c4fd07da73469742773';
const sourceStack = new cdk.Stack(app, 'SourceStack', {
env: {
account: sourceAccount,
Expand Down Expand Up @@ -982,7 +983,7 @@ describe('rule', () => {
const eventBusPolicyStack = app.node.findChild(`EventBusPolicy-${sourceAccount}-us-west-2-${targetAccount}`) as cdk.Stack;
Template.fromStack(eventBusPolicyStack).hasResourceProperties('AWS::Events::EventBusPolicy', {
'Action': 'events:PutEvents',
'StatementId': `Allow-account-${sourceAccount}`,
'StatementId': `Allow-account-${sourceAccount}-${nodeAddr}`,
'Principal': sourceAccount,
});
});
Expand Down

0 comments on commit a257846

Please sign in to comment.