Skip to content

Commit 4044dd4

Browse files
committed
fix(events): cannot use the same target account for 2 cross-account event sources
We hard code the SID of the EventBusPolicy that we generate in the account of the target of a cross-account CloudWatch Event rule. Which means that, if you have two sources in different accounts generating events into the same target account, you will get an error on CloudFormation deployment time about a duplicate SID. Include the source account ID when generating the SID to make it unique. Fixes #8010
1 parent 613df1b commit 4044dd4

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

packages/@aws-cdk/aws-events/lib/rule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ export class Rule extends Resource implements IRule {
244244
});
245245
new CfnEventBusPolicy(eventBusPolicyStack, 'GivePermToOtherAccount', {
246246
action: 'events:PutEvents',
247-
statementId: 'MySid',
247+
statementId: `Allow-account-${sourceAccount}`,
248248
principal: sourceAccount,
249249
});
250250
}

packages/@aws-cdk/aws-events/test/test.rule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ export = {
717717
const eventBusPolicyStack = app.node.findChild(`EventBusPolicy-${sourceAccount}-us-west-2-${targetAccount}`) as cdk.Stack;
718718
expect(eventBusPolicyStack).to(haveResourceLike('AWS::Events::EventBusPolicy', {
719719
'Action': 'events:PutEvents',
720-
'StatementId': 'MySid',
720+
'StatementId': `Allow-account-${sourceAccount}`,
721721
'Principal': sourceAccount,
722722
}));
723723

0 commit comments

Comments
 (0)