@gradientedge/cdk-utils 9.10.0 → 9.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -106,11 +106,11 @@ class ApiToEventBridgeTarget extends common_1.CommonConstruct {
106
106
  */
107
107
  createApiToEventBridgeTargetEventBus() {
108
108
  if (this.props.api.useExisting) {
109
- this.apiEvent.eventBus = aws_events_1.EventBus.fromEventBusName(this, `${this.id}-event-bus`, `${this.props.event.eventBusName}-${this.props.stage}`);
109
+ this.apiEvent.eventBus = aws_events_1.EventBus.fromEventBusName(this, `${this.id}-event-bus`, this.resourceNameFormatter(this.props.event.eventBusName ?? 'default'));
110
110
  return;
111
111
  }
112
112
  this.apiEvent.eventBus = this.eventManager.createEventBus(`${this.id}-event-bus`, this, {
113
- eventBusName: `${this.props.event.eventBusName}`,
113
+ eventBusName: this.props.event.eventBusName ?? 'default',
114
114
  });
115
115
  }
116
116
  /**
@@ -121,7 +121,7 @@ class ApiToEventBridgeTarget extends common_1.CommonConstruct {
121
121
  return;
122
122
  this.apiEvent.logGroup = this.logManager.createLogGroup(`${this.id}-log`, this, {
123
123
  ...{
124
- logGroupName: `/${this.id}/events/api-to-eventbridge-target`,
124
+ logGroupName: `/${this.resourceNameFormatter(this.id)}/events/api-to-eventbridge-target`,
125
125
  },
126
126
  ...this.props.event.logGroup,
127
127
  });
@@ -132,11 +132,12 @@ class ApiToEventBridgeTarget extends common_1.CommonConstruct {
132
132
  createApiToEventBridgeTargetRule() {
133
133
  if (this.props.api.useExisting)
134
134
  return;
135
+ if (!this.props.event.rule.ruleName)
136
+ throw `Event ruleName undefined for ${this.id}`;
135
137
  this.props.event.rule = {
136
138
  eventPattern: {
137
139
  source: ['api-to-eventbridge-target'],
138
140
  },
139
- ruleName: `${this.id}-api-to-eventbridge-target`,
140
141
  ...this.props.event.rule,
141
142
  };
142
143
  this.apiEvent.rule = this.eventManager.createRule(`${this.id}-api-to-eventbridge-target-rule`, this, this.props.event.rule, this.apiEvent.eventBus, [new aws_events_targets_1.CloudWatchLogGroup(this.apiEvent.logGroup)]);
@@ -289,7 +290,7 @@ class ApiToEventBridgeTarget extends common_1.CommonConstruct {
289
290
  }
290
291
  createApiToEventBridgeTargetRestApiLogGroup() {
291
292
  this.apiToEventBridgeTargetRestApi.accessLogGroup = this.logManager.createLogGroup(`${this.id}-rest-api-access-log`, this, {
292
- logGroupName: `/custom/api/${this.id}-rest-api-access`,
293
+ logGroupName: `/custom/api/${this.resourceNameFormatter(this.id)}-rest-api-access`,
293
294
  removalPolicy: aws_cdk_lib_1.RemovalPolicy.DESTROY,
294
295
  });
295
296
  }
@@ -114,7 +114,7 @@ class ApiToLambdaTarget extends common_1.CommonConstruct {
114
114
  return;
115
115
  }
116
116
  const accessLogGroup = this.logManager.createLogGroup(`${this.id}-rest-api-access-log`, this, {
117
- logGroupName: `/custom/api/${this.id}-rest-api-access`,
117
+ logGroupName: `/custom/api/${this.resourceNameFormatter(this.id)}-rest-api-access`,
118
118
  removalPolicy: aws_cdk_lib_1.RemovalPolicy.DESTROY,
119
119
  });
120
120
  this.props.api.restApi = {
@@ -49,7 +49,7 @@ class ApplicationConfiguration extends common_1.CommonConstruct {
49
49
  this.appConfigDeploymentStrategy = new aws_appconfig_1.CfnDeploymentStrategy(this, `${this.id}-ac-deployment-strategy`, {
50
50
  deploymentDurationInMinutes: this.props.appConfig.deploymentStrategy.deploymentDurationInMinutes,
51
51
  growthFactor: this.props.appConfig.deploymentStrategy.growthFactor,
52
- name: this.props.appConfig.deploymentStrategy.name,
52
+ name: this.resourceNameFormatter(this.props.appConfig.deploymentStrategy.name),
53
53
  replicateTo: this.props.appConfig.deploymentStrategy.replicateTo,
54
54
  });
55
55
  }
@@ -92,7 +92,7 @@ class AppConfigManager {
92
92
  ...props.configurationProfile,
93
93
  applicationId,
94
94
  locationUri: props.configurationProfile.locationUri || 'hosted',
95
- name: `${props.configurationProfile.name}-${scope.props.stage}`,
95
+ name: scope.resourceNameFormatter(props.configurationProfile.name, props.resourceNameOptions),
96
96
  });
97
97
  (0, utils_1.createCfnOutput)(`${id}-configurationProfileId`, scope, aws_cdk_lib_1.Fn.ref(profile.logicalId));
98
98
  (0, utils_1.createCfnOutput)(`${id}-configurationProfileName`, scope, profile.name);
@@ -39,9 +39,13 @@ class EventManager {
39
39
  throw `EventBus props undefined for ${id}`;
40
40
  if (!props.eventBusName)
41
41
  throw `EventBus eventBusName undefined for ${id}`;
42
+ let eventBusName = props.eventBusName;
43
+ if (eventBusName && eventBusName != 'default') {
44
+ eventBusName = scope.resourceNameFormatter(props.eventBusName, props.resourceNameOptions);
45
+ }
42
46
  const eventBus = new aws_events_1.EventBus(scope, `${id}`, {
43
47
  ...props,
44
- eventBusName: scope.resourceNameFormatter(props.eventBusName, props.resourceNameOptions),
48
+ eventBusName,
45
49
  });
46
50
  (0, utils_1.createCfnOutput)(`${id}-eventBusName`, scope, `${props.eventBusName}-${scope.props.stage}`);
47
51
  (0, utils_1.createCfnOutput)(`${id}-eventBusArn`, scope, eventBus.eventBusArn);
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "9.10.0",
3
+ "version": "9.10.1",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
7
7
  "node": ">=16 <=20",
8
- "pnpm": "=8"
8
+ "pnpm": "=9"
9
9
  },
10
10
  "packageManager": "pnpm@8.15.8",
11
11
  "repository": {
@@ -159,12 +159,12 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
159
159
  this.apiEvent.eventBus = EventBus.fromEventBusName(
160
160
  this,
161
161
  `${this.id}-event-bus`,
162
- `${this.props.event.eventBusName}-${this.props.stage}`
162
+ this.resourceNameFormatter(this.props.event.eventBusName ?? 'default')
163
163
  )
164
164
  return
165
165
  }
166
166
  this.apiEvent.eventBus = this.eventManager.createEventBus(`${this.id}-event-bus`, this, {
167
- eventBusName: `${this.props.event.eventBusName}`,
167
+ eventBusName: this.props.event.eventBusName ?? 'default',
168
168
  })
169
169
  }
170
170
 
@@ -175,7 +175,7 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
175
175
  if (this.props.api.useExisting) return
176
176
  this.apiEvent.logGroup = this.logManager.createLogGroup(`${this.id}-log`, this, {
177
177
  ...{
178
- logGroupName: `/${this.id}/events/api-to-eventbridge-target`,
178
+ logGroupName: `/${this.resourceNameFormatter(this.id)}/events/api-to-eventbridge-target`,
179
179
  },
180
180
  ...this.props.event.logGroup,
181
181
  })
@@ -186,11 +186,12 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
186
186
  */
187
187
  protected createApiToEventBridgeTargetRule() {
188
188
  if (this.props.api.useExisting) return
189
+ if (!this.props.event.rule.ruleName) throw `Event ruleName undefined for ${this.id}`
190
+
189
191
  this.props.event.rule = {
190
192
  eventPattern: {
191
193
  source: ['api-to-eventbridge-target'],
192
194
  },
193
- ruleName: `${this.id}-api-to-eventbridge-target`,
194
195
  ...this.props.event.rule,
195
196
  }
196
197
  this.apiEvent.rule = this.eventManager.createRule(
@@ -355,7 +356,7 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
355
356
  `${this.id}-rest-api-access-log`,
356
357
  this,
357
358
  {
358
- logGroupName: `/custom/api/${this.id}-rest-api-access`,
359
+ logGroupName: `/custom/api/${this.resourceNameFormatter(this.id)}-rest-api-access`,
359
360
  removalPolicy: RemovalPolicy.DESTROY,
360
361
  }
361
362
  )
@@ -156,7 +156,7 @@ export class ApiToLambdaTarget extends CommonConstruct {
156
156
  }
157
157
 
158
158
  const accessLogGroup = this.logManager.createLogGroup(`${this.id}-rest-api-access-log`, this, {
159
- logGroupName: `/custom/api/${this.id}-rest-api-access`,
159
+ logGroupName: `/custom/api/${this.resourceNameFormatter(this.id)}-rest-api-access`,
160
160
  removalPolicy: RemovalPolicy.DESTROY,
161
161
  })
162
162
 
@@ -79,7 +79,7 @@ export class ApplicationConfiguration extends CommonConstruct {
79
79
  this.appConfigDeploymentStrategy = new CfnDeploymentStrategy(this, `${this.id}-ac-deployment-strategy`, {
80
80
  deploymentDurationInMinutes: this.props.appConfig.deploymentStrategy.deploymentDurationInMinutes,
81
81
  growthFactor: this.props.appConfig.deploymentStrategy.growthFactor,
82
- name: this.props.appConfig.deploymentStrategy.name,
82
+ name: this.resourceNameFormatter(this.props.appConfig.deploymentStrategy.name),
83
83
  replicateTo: this.props.appConfig.deploymentStrategy.replicateTo,
84
84
  })
85
85
  }
@@ -109,7 +109,7 @@ export class AppConfigManager {
109
109
  ...props.configurationProfile,
110
110
  applicationId,
111
111
  locationUri: props.configurationProfile.locationUri || 'hosted',
112
- name: `${props.configurationProfile.name}-${scope.props.stage}`,
112
+ name: scope.resourceNameFormatter(props.configurationProfile.name, props.resourceNameOptions),
113
113
  })
114
114
 
115
115
  createCfnOutput(`${id}-configurationProfileId`, scope, Fn.ref(profile.logicalId))
@@ -45,9 +45,13 @@ export class EventManager {
45
45
  if (!props) throw `EventBus props undefined for ${id}`
46
46
  if (!props.eventBusName) throw `EventBus eventBusName undefined for ${id}`
47
47
 
48
+ let eventBusName = props.eventBusName
49
+ if (eventBusName && eventBusName != 'default') {
50
+ eventBusName = scope.resourceNameFormatter(props.eventBusName, props.resourceNameOptions)
51
+ }
48
52
  const eventBus = new EventBus(scope, `${id}`, {
49
53
  ...props,
50
- eventBusName: scope.resourceNameFormatter(props.eventBusName, props.resourceNameOptions),
54
+ eventBusName,
51
55
  })
52
56
 
53
57
  createCfnOutput(`${id}-eventBusName`, scope, `${props.eventBusName}-${scope.props.stage}`)