Skip to content

Commit 1503eaa

Browse files
committed
added appName for all resources
1 parent 05794d2 commit 1503eaa

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

typescript/eventbridge-mesh/lib/app.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,25 @@ import { consumerStack } from './single-consumer-stack';
44
import { producerStack } from './single-producer-stack';
55

66
const app = new cdk.App();
7-
7+
const appName = 'eventbridge-mesh'
88
const region = 'us-east-1'
9-
const producerAccountId = '111111111111';
10-
const consumerAccountId = '222222222222';
9+
const producerAccountId = '123510061335';
10+
const consumerAccountId = '737719307477';
1111

12-
new producerStack(app, 'producerStack', {
12+
new producerStack(app, `${appName}-producer-stack`, {
1313
env: {
1414
account: producerAccountId,
1515
region: region,
1616
},
17+
appName,
1718
consumerAccountId,
1819
});
1920

20-
new consumerStack(app, 'consumerStack', {
21+
new consumerStack(app, `${appName}-consumer-stack`, {
2122
env: {
2223
account: consumerAccountId,
2324
region: region,
2425
},
26+
appName,
2527
producerAccountId,
2628
});

typescript/eventbridge-mesh/lib/single-consumer-stack.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { LogGroup } from 'aws-cdk-lib/aws-logs';
66
import { Construct } from 'constructs';
77

88
export interface consumerStackProps extends cdk.StackProps {
9+
readonly appName: string;
910
readonly producerAccountId: string;
1011
}
1112

@@ -14,7 +15,7 @@ export class consumerStack extends cdk.Stack {
1415
super(scope, id, props);
1516

1617
// Create or reference the consumer event bus
17-
const consumerEventBus = new EventBus(this, 'ConsumerEventBus');
18+
const consumerEventBus = new EventBus(this, `${props.appName}-consumer-event-bus`);
1819

1920
// Add policy to allow producer account to put events
2021
consumerEventBus.addToResourcePolicy(new PolicyStatement({
@@ -26,7 +27,7 @@ export class consumerStack extends cdk.Stack {
2627
}));
2728

2829
// Create consumer rules
29-
const consumerRule = new Rule(this, 'ConsumerRule', {
30+
const consumerRule = new Rule(this, `${props.appName}-consumer-rule`, {
3031
eventBus: consumerEventBus,
3132
eventPattern: {
3233
// Define more specific filtering here
@@ -39,7 +40,7 @@ export class consumerStack extends cdk.Stack {
3940

4041
// Add target (e.g., CloudWatch)
4142
consumerRule.addTarget(new CloudWatchLogGroup(
42-
new LogGroup(this, 'ConsumerLogs')
43+
new LogGroup(this, `${props.appName}-consumer-logs`)
4344
));
4445
}
4546
}

typescript/eventbridge-mesh/lib/single-producer-stack.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { LogGroup } from 'aws-cdk-lib/aws-logs';
55
import { Construct } from 'constructs';
66

77
export interface producerStackProps extends cdk.StackProps {
8+
readonly appName: string;
89
readonly consumerAccountId: string;
910
}
1011

@@ -13,10 +14,10 @@ export class producerStack extends cdk.Stack {
1314
super(scope, id, props);
1415

1516
// Create the EventBus
16-
const producerEventBus = new EventBus(this, 'ProducerEventBus');
17+
const producerEventBus = new EventBus(this, `${props.appName}-producer-event-bus`);
1718

1819
// Create rule to forward events to consumer account
19-
const rule = new Rule(this, 'ForwardToConsumerRule', {
20+
const rule = new Rule(this, `${props.appName}-forward-to-consumer-rule`, {
2021
eventBus: producerEventBus,
2122
eventPattern: {
2223
// Define your event pattern here
@@ -35,7 +36,7 @@ export class producerStack extends cdk.Stack {
3536

3637
// Optional: Add CloudWatch target for monitoring
3738
rule.addTarget(new targets.CloudWatchLogGroup(
38-
new LogGroup(this, 'producerLogs')
39+
new LogGroup(this, `${props.appName}-producer-logs`)
3940
));
4041
}
4142
}

0 commit comments

Comments
 (0)