Skip to content

Commit

Permalink
Merge branch 'main' into scanlonp-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Jun 6, 2024
2 parents f660473 + a05591d commit 73dc1b5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/aws-cdk-lib/aws-events/lib/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ export class Rule extends Resource implements IRule {
errors.push('Either \'eventPattern\' or \'schedule\' must be defined');
}

if (this.targets.length > 5) {
errors.push('Event rule cannot have more than 5 targets.');
}

return errors;
}

Expand Down
19 changes: 19 additions & 0 deletions packages/aws-cdk-lib/aws-events/test/rule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,25 @@ describe('rule', () => {
});
});

test('rule cannot have more than 5 targets', () => {
const app = new cdk.App();
const stack = new cdk.Stack(app);
const resource = new Construct(stack, 'Resource');
const rule = new Rule(stack, 'MyRule', {
schedule: Schedule.rate(cdk.Duration.minutes(10)),
targets: [
new SomeTarget('T1', resource),
new SomeTarget('T2', resource),
new SomeTarget('T3', resource),
new SomeTarget('T4', resource),
new SomeTarget('T5', resource),
new SomeTarget('T6', resource),
],
});

expect(() => app.synth()).toThrow(/Event rule cannot have more than 5 targets./);
});

test('get rate as token', () => {
const app = new cdk.App();
const stack = new cdk.Stack(app, 'MyScheduledStack');
Expand Down

0 comments on commit 73dc1b5

Please sign in to comment.