Skip to content

Commit

Permalink
Merge branch 'main' into synthetics-runconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Jul 31, 2024
2 parents 07cdc78 + 28fbc82 commit ee9f60d
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 49 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"BusEA82B648": {
"Type": "AWS::Events::EventBus",
"Properties": {
"Description": "myEventBus",
"Name": "StackBusAA0A1E4B"
}
},
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { EventBus } from 'aws-cdk-lib/aws-events';

const app = new App();
const stack = new Stack(app, 'Stack');
const bus = new EventBus(stack, 'Bus');
const bus = new EventBus(stack, 'Bus', {
description: 'myEventBus',
});

bus.addToResourcePolicy(new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
Expand Down
3 changes: 2 additions & 1 deletion packages/aws-cdk-lib/aws-events/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ It is possible to archive all or some events sent to an event bus. It is then po

```ts
const bus = new events.EventBus(this, 'bus', {
eventBusName: 'MyCustomEventBus'
eventBusName: 'MyCustomEventBus',
description: 'MyCustomEventBus',
});

bus.archive('MyArchive', {
Expand Down
16 changes: 16 additions & 0 deletions packages/aws-cdk-lib/aws-events/lib/event-bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ export interface EventBusProps {
*/
readonly eventSourceName?: string;

/**
* The event bus description.
*
* The description can be up to 512 characters long.
*
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-eventbus.html#cfn-events-eventbus-description
*
* @default - no description
*/
readonly description?: string;

/**
* The customer managed key that encrypt events on this event bus.
*
Expand Down Expand Up @@ -325,9 +336,14 @@ export class EventBus extends EventBusBase {

super(scope, id, { physicalName: eventBusName });

if (props?.description && !Token.isUnresolved(props.description) && props.description.length > 512) {
throw new Error(`description must be less than or equal to 512 characters, got ${props.description.length}`);
}

const eventBus = new CfnEventBus(this, 'Resource', {
name: this.physicalName,
eventSourceName,
description: props?.description,
kmsKeyIdentifier: props?.kmsKey?.keyArn,
});

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

test('event bus with description', () => {
// GIVEN
const stack = new Stack();

// WHEN
new EventBus(stack, 'myEventBus', {
description: 'myEventBusDescription',
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::Events::EventBus', {
Description: 'myEventBusDescription',
});
});

test('partner event bus', () => {
// GIVEN
const stack = new Stack();
Expand Down Expand Up @@ -281,6 +296,19 @@ describe('event bus', () => {
}).toThrow(/'eventSourceName' must satisfy: /);
});

test('event bus description cannot be too long', () => {
// GIVEN
const stack = new Stack();
const tooLongDescription = 'a'.repeat(513);

// WHEN / THEN
expect(() => {
new EventBus(stack, 'EventBusWithTooLongDescription', {
description: tooLongDescription,
});
}).toThrow('description must be less than or equal to 512 characters, got 513');
});

testDeprecated('can grant PutEvents', () => {
// GIVEN
const stack = new Stack();
Expand Down

0 comments on commit ee9f60d

Please sign in to comment.