@gradientedge/cdk-utils 9.10.0 → 9.11.0

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.
Files changed (63) hide show
  1. package/dist/src/lib/aws/common/construct.d.ts +3 -8
  2. package/dist/src/lib/aws/common/construct.js +3 -14
  3. package/dist/src/lib/aws/common/resource-name-formatter.d.ts +13 -0
  4. package/dist/src/lib/aws/common/resource-name-formatter.js +26 -0
  5. package/dist/src/lib/aws/construct/api-to-any-target/main.js +1 -1
  6. package/dist/src/lib/aws/construct/api-to-eventbridge-target/main.js +7 -6
  7. package/dist/src/lib/aws/construct/api-to-eventbridge-target-with-sns/main.js +2 -2
  8. package/dist/src/lib/aws/construct/api-to-lambda-target/main.js +2 -2
  9. package/dist/src/lib/aws/construct/application-configuration/main.js +1 -1
  10. package/dist/src/lib/aws/construct/lambda-with-iam-access/main.js +3 -3
  11. package/dist/src/lib/aws/construct/site-with-ecs-backend/main.js +7 -7
  12. package/dist/src/lib/aws/construct/site-with-lambda-backend/main.js +3 -3
  13. package/dist/src/lib/aws/services/api-gateway/main.js +1 -1
  14. package/dist/src/lib/aws/services/appconfig/main.js +2 -2
  15. package/dist/src/lib/aws/services/cloudfront/main.js +2 -2
  16. package/dist/src/lib/aws/services/cloudtrail/main.js +1 -1
  17. package/dist/src/lib/aws/services/dynamodb/main.js +1 -1
  18. package/dist/src/lib/aws/services/elastic-container-service/main.js +2 -2
  19. package/dist/src/lib/aws/services/elastic-file-system/main.js +1 -1
  20. package/dist/src/lib/aws/services/elastic-kubernetes-service/main.js +1 -1
  21. package/dist/src/lib/aws/services/elasticache/main.js +1 -1
  22. package/dist/src/lib/aws/services/eventbridge/main.js +13 -9
  23. package/dist/src/lib/aws/services/evidently/main.js +4 -4
  24. package/dist/src/lib/aws/services/identity-access-management/main.js +10 -10
  25. package/dist/src/lib/aws/services/lambda/main.js +2 -2
  26. package/dist/src/lib/aws/services/secrets-manager/main.js +1 -1
  27. package/dist/src/lib/aws/services/simple-notification-service/main.js +4 -4
  28. package/dist/src/lib/aws/services/simple-queue-service/main.js +1 -1
  29. package/dist/src/lib/aws/services/simple-storage-service/main.js +1 -1
  30. package/dist/src/lib/aws/services/step-function/main.js +1 -1
  31. package/dist/src/lib/aws/services/virtual-private-cloud/main.js +3 -3
  32. package/dist/src/lib/aws/services/web-application-firewall/main.js +2 -2
  33. package/package.json +2 -2
  34. package/src/lib/aws/common/construct.ts +4 -16
  35. package/src/lib/aws/common/resource-name-formatter.ts +26 -0
  36. package/src/lib/aws/construct/api-to-any-target/main.ts +1 -1
  37. package/src/lib/aws/construct/api-to-eventbridge-target/main.ts +7 -6
  38. package/src/lib/aws/construct/api-to-eventbridge-target-with-sns/main.ts +2 -2
  39. package/src/lib/aws/construct/api-to-lambda-target/main.ts +2 -2
  40. package/src/lib/aws/construct/application-configuration/main.ts +1 -1
  41. package/src/lib/aws/construct/lambda-with-iam-access/main.ts +3 -3
  42. package/src/lib/aws/construct/site-with-ecs-backend/main.ts +9 -7
  43. package/src/lib/aws/construct/site-with-lambda-backend/main.ts +5 -3
  44. package/src/lib/aws/services/api-gateway/main.ts +1 -1
  45. package/src/lib/aws/services/appconfig/main.ts +2 -2
  46. package/src/lib/aws/services/cloudfront/main.ts +2 -2
  47. package/src/lib/aws/services/cloudtrail/main.ts +1 -1
  48. package/src/lib/aws/services/dynamodb/main.ts +1 -1
  49. package/src/lib/aws/services/elastic-container-service/main.ts +2 -2
  50. package/src/lib/aws/services/elastic-file-system/main.ts +1 -1
  51. package/src/lib/aws/services/elastic-kubernetes-service/main.ts +1 -1
  52. package/src/lib/aws/services/elasticache/main.ts +1 -1
  53. package/src/lib/aws/services/eventbridge/main.ts +13 -9
  54. package/src/lib/aws/services/evidently/main.ts +4 -4
  55. package/src/lib/aws/services/identity-access-management/main.ts +10 -10
  56. package/src/lib/aws/services/lambda/main.ts +2 -2
  57. package/src/lib/aws/services/secrets-manager/main.ts +1 -1
  58. package/src/lib/aws/services/simple-notification-service/main.ts +4 -4
  59. package/src/lib/aws/services/simple-queue-service/main.ts +1 -1
  60. package/src/lib/aws/services/simple-storage-service/main.ts +1 -1
  61. package/src/lib/aws/services/step-function/main.ts +1 -1
  62. package/src/lib/aws/services/virtual-private-cloud/main.ts +3 -3
  63. package/src/lib/aws/services/web-application-firewall/main.ts +2 -2
@@ -1,7 +1,8 @@
1
1
  import { CfnOutput } from 'aws-cdk-lib';
2
2
  import { Construct } from 'constructs';
3
3
  import { AcmManager, ApiManager, AppConfigManager, CloudFrontManager, CloudTrailManager, CloudWatchManager, CodeBuildManager, DynamodbManager, EcrManager, EcsManager, EfsManager, EksManager, ElastiCacheManager, EventManager, EventTargetManager, EvidentlyManager, IamManager, KmsManager, LambdaManager, LogManager, Route53Manager, S3Manager, SecretsManager, SfnManager, SnsManager, SqsManager, SsmManager, VpcManager, WafManager } from '../services';
4
- import { CommonStackProps, ResourceNameFormatterProps } from './types';
4
+ import { ResourceNameFormatter } from './resource-name-formatter';
5
+ import { CommonStackProps } from './types';
5
6
  /**
6
7
  * @subcategory Construct
7
8
  * @classdesc Common construct to use as a base for all higher level constructs.
@@ -17,6 +18,7 @@ import { CommonStackProps, ResourceNameFormatterProps } from './types';
17
18
  */
18
19
  export declare class CommonConstruct extends Construct {
19
20
  props: CommonStackProps;
21
+ resourceNameFormatter: ResourceNameFormatter;
20
22
  acmManager: AcmManager;
21
23
  apiManager: ApiManager;
22
24
  appConfigManager: AppConfigManager;
@@ -48,13 +50,6 @@ export declare class CommonConstruct extends Construct {
48
50
  wafManager: WafManager;
49
51
  fullyQualifiedDomainName: string;
50
52
  constructor(parent: Construct, id: string, props: CommonStackProps);
51
- /**
52
- * @summary Helper method to format a resource name based on the provided options
53
- * @param resourceName the resource name to format
54
- * @param options options to control the formatting of the resource name
55
- * @returns The formatted resource name
56
- */
57
- resourceNameFormatter(resourceName: string, options?: ResourceNameFormatterProps): string;
58
53
  /**
59
54
  * @summary Helper method to add CloudFormation outputs from the construct
60
55
  * @param id scoped id of the resource
@@ -5,6 +5,7 @@ const constructs_1 = require("constructs");
5
5
  const common_1 = require("../../common");
6
6
  const services_1 = require("../services");
7
7
  const utils_1 = require("../utils");
8
+ const resource_name_formatter_1 = require("./resource-name-formatter");
8
9
  /**
9
10
  * @subcategory Construct
10
11
  * @classdesc Common construct to use as a base for all higher level constructs.
@@ -20,6 +21,7 @@ const utils_1 = require("../utils");
20
21
  */
21
22
  class CommonConstruct extends constructs_1.Construct {
22
23
  props;
24
+ resourceNameFormatter;
23
25
  acmManager;
24
26
  apiManager;
25
27
  appConfigManager;
@@ -53,6 +55,7 @@ class CommonConstruct extends constructs_1.Construct {
53
55
  constructor(parent, id, props) {
54
56
  super(parent, id);
55
57
  this.props = props;
58
+ this.resourceNameFormatter = new resource_name_formatter_1.ResourceNameFormatter(this, `${id}-rnf`, props);
56
59
  this.acmManager = new services_1.AcmManager();
57
60
  this.apiManager = new services_1.ApiManager();
58
61
  this.appConfigManager = new services_1.AppConfigManager();
@@ -84,20 +87,6 @@ class CommonConstruct extends constructs_1.Construct {
84
87
  this.wafManager = new services_1.WafManager();
85
88
  this.determineFullyQualifiedDomain();
86
89
  }
87
- /**
88
- * @summary Helper method to format a resource name based on the provided options
89
- * @param resourceName the resource name to format
90
- * @param options options to control the formatting of the resource name
91
- * @returns The formatted resource name
92
- */
93
- resourceNameFormatter(resourceName, options) {
94
- const resourceNameElements = [];
95
- resourceNameElements.push(options?.prefix ?? this.props.resourcePrefix);
96
- resourceNameElements.push(resourceName);
97
- resourceNameElements.push(options?.suffix ?? this.props.resourceSuffix);
98
- resourceNameElements.push(this.props.stage);
99
- return resourceNameElements.filter(resourceNameElement => resourceNameElement != undefined).join('-');
100
- }
101
90
  /**
102
91
  * @summary Helper method to add CloudFormation outputs from the construct
103
92
  * @param id scoped id of the resource
@@ -0,0 +1,13 @@
1
+ import { Construct } from 'constructs';
2
+ import { CommonStackProps, ResourceNameFormatterProps } from './types';
3
+ export declare class ResourceNameFormatter extends Construct {
4
+ props: CommonStackProps;
5
+ constructor(parent: Construct, id: string, props: CommonStackProps);
6
+ /**
7
+ * @summary Helper method to format a resource name based on the provided options
8
+ * @param resourceName the resource name to format
9
+ * @param options options to control the formatting of the resource name
10
+ * @returns The formatted resource name
11
+ */
12
+ format(resourceName: string, options?: ResourceNameFormatterProps): string;
13
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ResourceNameFormatter = void 0;
4
+ const constructs_1 = require("constructs");
5
+ class ResourceNameFormatter extends constructs_1.Construct {
6
+ props;
7
+ constructor(parent, id, props) {
8
+ super(parent, id);
9
+ this.props = props;
10
+ }
11
+ /**
12
+ * @summary Helper method to format a resource name based on the provided options
13
+ * @param resourceName the resource name to format
14
+ * @param options options to control the formatting of the resource name
15
+ * @returns The formatted resource name
16
+ */
17
+ format(resourceName, options) {
18
+ const resourceNameElements = [];
19
+ resourceNameElements.push(options?.prefix ?? this.props.resourcePrefix);
20
+ resourceNameElements.push(resourceName);
21
+ resourceNameElements.push(options?.suffix ?? this.props.resourceSuffix);
22
+ resourceNameElements.push(this.props.stage);
23
+ return resourceNameElements.filter(resourceNameElement => resourceNameElement != undefined).join('-');
24
+ }
25
+ }
26
+ exports.ResourceNameFormatter = ResourceNameFormatter;
@@ -112,7 +112,7 @@ class ApiToAnyTarget extends common_1.CommonConstruct {
112
112
  types: [this.isProductionStage() ? aws_apigateway_1.EndpointType.EDGE : aws_apigateway_1.EndpointType.REGIONAL],
113
113
  },
114
114
  ...this.props.api.restApi,
115
- restApiName: this.resourceNameFormatter(this.props.api.restApi?.restApiName, this.props.api.restApi?.resourceNameOptions),
115
+ restApiName: this.resourceNameFormatter.format(this.props.api.restApi?.restApiName, this.props.api.restApi?.resourceNameOptions),
116
116
  });
117
117
  this.addCfnOutput(`${this.id}-restApiId`, this.apiToAnyTargetRestApi.api.restApiId);
118
118
  this.addCfnOutput(`${this.id}-restApiRootResourceId`, this.apiToAnyTargetRestApi.api.root.resourceId);
@@ -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.format(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.format(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.format(this.id)}-rest-api-access`,
293
294
  removalPolicy: aws_cdk_lib_1.RemovalPolicy.DESTROY,
294
295
  });
295
296
  }
@@ -332,7 +333,7 @@ class ApiToEventBridgeTarget extends common_1.CommonConstruct {
332
333
  types: [aws_apigateway_1.EndpointType.REGIONAL],
333
334
  },
334
335
  ...this.props.api.restApi,
335
- restApiName: this.resourceNameFormatter(this.props.api.restApi?.restApiName, this.props.api.restApi?.resourceNameOptions),
336
+ restApiName: this.resourceNameFormatter.format(this.props.api.restApi?.restApiName, this.props.api.restApi?.resourceNameOptions),
336
337
  });
337
338
  this.addCfnOutput(`${this.id}-restApiId`, this.apiToEventBridgeTargetRestApi.api.restApiId);
338
339
  this.addCfnOutput(`${this.id}-restApiRootResourceId`, this.apiToEventBridgeTargetRestApi.api.root.resourceId);
@@ -271,7 +271,7 @@ class ApiToEventBridgeTargetWithSns extends common_1.CommonConstruct {
271
271
  if (!this.props.api.withResource)
272
272
  return;
273
273
  this.apiDestinedRestApi.topic = this.snsManager.createLambdaNotificationService(`${this.id}-destined-topic`, this, {
274
- topicName: this.resourceNameFormatter(`${this.id}-destined-topic`),
274
+ topicName: this.resourceNameFormatter.format(`${this.id}-destined-topic`),
275
275
  }, this.apiDestinedLambda.function);
276
276
  if (this.apiDestinedRestApi.role) {
277
277
  this.apiDestinedRestApi.topic.grantPublish(this.apiDestinedRestApi.role);
@@ -438,7 +438,7 @@ class ApiToEventBridgeTargetWithSns extends common_1.CommonConstruct {
438
438
  types: [aws_apigateway_1.EndpointType.REGIONAL],
439
439
  },
440
440
  ...this.props.api,
441
- restApiName: this.resourceNameFormatter(this.props.api.restApi?.restApiName, this.props.api.restApi?.resourceNameOptions),
441
+ restApiName: this.resourceNameFormatter.format(this.props.api.restApi?.restApiName, this.props.api.restApi?.resourceNameOptions),
442
442
  });
443
443
  this.addCfnOutput(`${this.id}-restApiId`, this.apiDestinedRestApi.api.restApiId);
444
444
  this.addCfnOutput(`${this.id}-restApiRootResourceId`, this.apiDestinedRestApi.api.root.resourceId);
@@ -103,7 +103,7 @@ class ApiToLambdaTarget extends common_1.CommonConstruct {
103
103
  };
104
104
  }
105
105
  resolveApiToLambdaTargetFunction() {
106
- this.apiToLambdaTargetRestApi.lambda = aws_lambda_1.Function.fromFunctionName(this, `${this.id}-lambda`, this.resourceNameFormatter(this.props.lambdaFunctionName));
106
+ this.apiToLambdaTargetRestApi.lambda = aws_lambda_1.Function.fromFunctionName(this, `${this.id}-lambda`, this.resourceNameFormatter.format(this.props.lambdaFunctionName));
107
107
  }
108
108
  /**
109
109
  * @summary Method to create rest restApi for Api
@@ -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.format(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.format(this.props.appConfig.deploymentStrategy.name),
53
53
  replicateTo: this.props.appConfig.deploymentStrategy.replicateTo,
54
54
  });
55
55
  }
@@ -143,10 +143,10 @@ class LambdaWithIamAccess extends common_1.CommonConstruct {
143
143
  */
144
144
  createIamUserForLambdaFunction() {
145
145
  this.lambdaIamUser = new aws_iam_1.User(this, `${this.id}-lambda-user`, {
146
- userName: this.resourceNameFormatter(`${this.id}-user`),
146
+ userName: this.resourceNameFormatter.format(`${this.id}-user`),
147
147
  });
148
148
  new aws_iam_1.Policy(this, `${this.id}-lambda-user-policy`, {
149
- policyName: this.resourceNameFormatter(`${this.id}-policy`),
149
+ policyName: this.resourceNameFormatter.format(`${this.id}-policy`),
150
150
  statements: [
151
151
  new aws_iam_1.PolicyStatement({
152
152
  actions: ['lambda:InvokeFunction'],
@@ -158,7 +158,7 @@ class LambdaWithIamAccess extends common_1.CommonConstruct {
158
158
  if (this.props.lambda.lambdaAliases && !lodash_1.default.isEmpty(this.props.lambda.lambdaAliases)) {
159
159
  lodash_1.default.forEach(this.props.lambda.lambdaAliases, (alias, index) => {
160
160
  new aws_iam_1.Policy(this, `${this.id}-alias-user-policy`, {
161
- policyName: this.resourceNameFormatter(`${this.id}--alias-policy-${index}`),
161
+ policyName: this.resourceNameFormatter.format(`${this.id}--alias-policy-${index}`),
162
162
  statements: [
163
163
  new aws_iam_1.PolicyStatement({
164
164
  actions: ['lambda:InvokeFunction'],
@@ -220,11 +220,11 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
220
220
  enableECSManagedTags: true,
221
221
  healthCheckGracePeriod: aws_cdk_lib_1.Duration.seconds(60),
222
222
  listenerPort: this.props.siteTask.listenerPort,
223
- loadBalancerName: this.resourceNameFormatter(this.props.siteTask.loadBalancerName ?? this.id),
223
+ loadBalancerName: this.resourceNameFormatter.format(this.props.siteTask.loadBalancerName ?? this.id),
224
224
  maxHealthyPercent: this.props.siteTask.maxHealthyPercent,
225
225
  memoryLimitMiB: this.props.siteTask.memoryLimitMiB,
226
226
  minHealthyPercent: this.props.siteTask.minHealthyPercent,
227
- serviceName: this.resourceNameFormatter(this.props.siteTask.serviceName ?? this.id),
227
+ serviceName: this.resourceNameFormatter.format(this.props.siteTask.serviceName ?? this.id),
228
228
  taskDefinition: this.props.siteTask.taskDefinition,
229
229
  taskImageOptions: {
230
230
  containerPort: this.props.siteTask.taskImageOptions?.containerPort,
@@ -304,14 +304,14 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
304
304
  transitEncryption: this.props.siteFileSystem.transitEncryption,
305
305
  transitEncryptionPort: this.props.siteFileSystem.transitEncryptionPort,
306
306
  },
307
- name: this.resourceNameFormatter(this.props.siteFileSystem?.fileSystemName ?? this.id),
307
+ name: this.resourceNameFormatter.format(this.props.siteFileSystem?.fileSystemName ?? this.id),
308
308
  });
309
309
  if (this.props.siteTask.mountPoints && !lodash_1.default.isEmpty(this.props.siteTask.mountPoints)) {
310
310
  lodash_1.default.forEach(this.props.siteTask.mountPoints, mountPoint => {
311
311
  this.siteEcsTaskDefinition.defaultContainer?.addMountPoints({
312
312
  containerPath: mountPoint.containerPath,
313
313
  readOnly: mountPoint.readOnly,
314
- sourceVolume: this.resourceNameFormatter(this.props.siteFileSystem?.fileSystemName ?? this.id),
314
+ sourceVolume: this.resourceNameFormatter.format(this.props.siteFileSystem?.fileSystemName ?? this.id),
315
315
  });
316
316
  });
317
317
  }
@@ -331,7 +331,7 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
331
331
  if (!siteCachePolicy.cachePolicyName)
332
332
  throw `SiteCachePolicy cachePolicyName undefined for ${id}`;
333
333
  return new aws_cloudfront_1.CachePolicy(this, `${id}`, {
334
- cachePolicyName: this.resourceNameFormatter(siteCachePolicy.cachePolicyName),
334
+ cachePolicyName: this.resourceNameFormatter.format(siteCachePolicy.cachePolicyName),
335
335
  comment: `Policy for ${this.id}-distribution - ${this.props.stage} stage`,
336
336
  cookieBehavior: siteCachePolicy.cookieBehavior,
337
337
  enableAcceptEncodingBrotli: siteCachePolicy.enableAcceptEncodingBrotli,
@@ -359,7 +359,7 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
359
359
  comment: `Request Policy for ${this.id}-distribution - ${this.props.stage} stage`,
360
360
  cookieBehavior: this.props.siteOriginRequestPolicy.cookieBehavior,
361
361
  headerBehavior: this.props.siteOriginRequestPolicy.headerBehavior,
362
- originRequestPolicyName: this.resourceNameFormatter(this.props.siteOriginRequestPolicy.originRequestPolicyName),
362
+ originRequestPolicyName: this.resourceNameFormatter.format(this.props.siteOriginRequestPolicy.originRequestPolicyName),
363
363
  queryStringBehavior: this.props.siteOriginRequestPolicy.queryStringBehavior,
364
364
  });
365
365
  lodash_1.default.assign(this.props.siteDistribution.defaultBehavior, {
@@ -374,7 +374,7 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
374
374
  return new aws_cloudfront_1.ResponseHeadersPolicy(this, `${this.id}-${props.type}-srhp`, {
375
375
  ...props,
376
376
  comment: `Response Header Policy for ${props.type} for ${this.id}-distribution - ${this.props.stage} stage`,
377
- responseHeadersPolicyName: this.resourceNameFormatter(props.responseHeadersPolicyName),
377
+ responseHeadersPolicyName: this.resourceNameFormatter.format(props.responseHeadersPolicyName),
378
378
  securityHeadersBehavior: {
379
379
  ...props.securityHeadersBehavior,
380
380
  strictTransportSecurity: {
@@ -139,7 +139,7 @@ class SiteWithLambdaBackend extends common_1.CommonConstruct {
139
139
  if (!siteCachePolicy.cachePolicyName)
140
140
  throw `SiteCachePolicy cachePolicyName undefined for ${id}`;
141
141
  return new aws_cloudfront_1.CachePolicy(this, `${id}`, {
142
- cachePolicyName: this.resourceNameFormatter(siteCachePolicy.cachePolicyName),
142
+ cachePolicyName: this.resourceNameFormatter.format(siteCachePolicy.cachePolicyName),
143
143
  comment: `Policy for ${this.id}-distribution - ${this.props.stage} stage`,
144
144
  cookieBehavior: siteCachePolicy.cookieBehavior,
145
145
  enableAcceptEncodingBrotli: siteCachePolicy.enableAcceptEncodingBrotli,
@@ -167,7 +167,7 @@ class SiteWithLambdaBackend extends common_1.CommonConstruct {
167
167
  comment: `Request Policy for ${this.id}-distribution - ${this.props.stage} stage`,
168
168
  cookieBehavior: this.props.siteOriginRequestPolicy.cookieBehavior,
169
169
  headerBehavior: this.props.siteOriginRequestPolicy.headerBehavior,
170
- originRequestPolicyName: this.resourceNameFormatter(this.props.siteOriginRequestPolicy.originRequestPolicyName),
170
+ originRequestPolicyName: this.resourceNameFormatter.format(this.props.siteOriginRequestPolicy.originRequestPolicyName),
171
171
  queryStringBehavior: this.props.siteOriginRequestPolicy.queryStringBehavior,
172
172
  });
173
173
  lodash_1.default.assign(this.props.siteDistribution.defaultBehavior, {
@@ -182,7 +182,7 @@ class SiteWithLambdaBackend extends common_1.CommonConstruct {
182
182
  return new aws_cloudfront_1.ResponseHeadersPolicy(this, `${this.id}-${props.type}-srhp`, {
183
183
  ...props,
184
184
  comment: `Response Header Policy for ${props.type} for ${this.id}-distribution - ${this.props.stage} stage`,
185
- responseHeadersPolicyName: this.resourceNameFormatter(props.responseHeadersPolicyName),
185
+ responseHeadersPolicyName: this.resourceNameFormatter.format(props.responseHeadersPolicyName),
186
186
  securityHeadersBehavior: {
187
187
  ...props.securityHeadersBehavior,
188
188
  strictTransportSecurity: {
@@ -55,7 +55,7 @@ class ApiManager {
55
55
  handler: lambdaFunction,
56
56
  minCompressionSize: props.minCompressionSizeInBytes ? aws_cdk_lib_1.Size.bytes(props.minCompressionSizeInBytes) : undefined,
57
57
  proxy: props.proxy ?? true,
58
- restApiName: scope.resourceNameFormatter(props.restApiName, props.resourceNameOptions),
58
+ restApiName: scope.resourceNameFormatter.format(props.restApiName, props.resourceNameOptions),
59
59
  });
60
60
  if (props.tags && !lodash_1.default.isEmpty(props.tags)) {
61
61
  lodash_1.default.forEach(props.tags, tag => {
@@ -50,7 +50,7 @@ class AppConfigManager {
50
50
  throw `AppConfig props undefined for ${id}`;
51
51
  const application = new aws_appconfig_1.CfnApplication(scope, `${id}`, {
52
52
  ...props.application,
53
- name: scope.resourceNameFormatter(props.application.name, props.resourceNameOptions),
53
+ name: scope.resourceNameFormatter.format(props.application.name, props.resourceNameOptions),
54
54
  });
55
55
  (0, utils_1.createCfnOutput)(`${id}-ApplicationId`, scope, aws_cdk_lib_1.Fn.ref(application.logicalId));
56
56
  (0, utils_1.createCfnOutput)(`${id}-ApplicationName`, scope, application.name);
@@ -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.format(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);
@@ -237,7 +237,7 @@ class CloudFrontManager {
237
237
  ...environment,
238
238
  },
239
239
  filesystem: accessPoint ? aws_lambda_1.FileSystem.fromEfsAccessPoint(accessPoint, mountPath ?? '/mnt/msg') : undefined,
240
- functionName: scope.resourceNameFormatter(props.functionName, props.resourceNameOptions),
240
+ functionName: scope.resourceNameFormatter.format(props.functionName, props.resourceNameOptions),
241
241
  handler: props.handler ?? 'index.handler',
242
242
  layers: layers,
243
243
  logRetention: props.logRetention,
@@ -297,7 +297,7 @@ class CloudFrontManager {
297
297
  filePath: props.functionFilePath,
298
298
  }),
299
299
  comment: props.comment,
300
- functionName: scope.resourceNameFormatter(props.functionName, props.resourceNameOptions),
300
+ functionName: scope.resourceNameFormatter.format(props.functionName, props.resourceNameOptions),
301
301
  });
302
302
  (0, utils_1.createCfnOutput)(`${id}-functionArn`, scope, cloudfrontFunction.functionArn);
303
303
  (0, utils_1.createCfnOutput)(`${id}-functionName`, scope, cloudfrontFunction.functionName);
@@ -62,7 +62,7 @@ class CloudTrailManager {
62
62
  s3BucketName: logBucket.bucketName,
63
63
  s3KeyPrefix: `logs-${props.trailName}`,
64
64
  tags: [{ key: 'service', value: scope.props.name }],
65
- trailName: scope.resourceNameFormatter(props.trailName, props.resourceNameOptions),
65
+ trailName: scope.resourceNameFormatter.format(props.trailName, props.resourceNameOptions),
66
66
  });
67
67
  cloudTrail.addDependency(logBucketPolicy);
68
68
  cloudTrail.addDependency(logGroup);
@@ -60,7 +60,7 @@ class DynamodbManager {
60
60
  throw `Table tableName undefined for ${id}`;
61
61
  const table = new aws_dynamodb_1.TableV2(scope, `${id}`, {
62
62
  ...props,
63
- tableName: scope.resourceNameFormatter(props.tableName, props.resourceNameOptions),
63
+ tableName: scope.resourceNameFormatter.format(props.tableName, props.resourceNameOptions),
64
64
  });
65
65
  (0, utils_1.createCfnOutput)(`${id}-tableName`, scope, table.tableName);
66
66
  (0, utils_1.createCfnOutput)(`${id}-tableArn`, scope, table.tableArn);
@@ -125,12 +125,12 @@ class EcsManager {
125
125
  cluster,
126
126
  enableECSManagedTags: true,
127
127
  healthCheckGracePeriod: props.healthCheckGracePeriod ?? aws_cdk_lib_1.Duration.seconds(60),
128
- loadBalancerName: scope.resourceNameFormatter(props.loadBalancerName, props.resourceNameOptions),
128
+ loadBalancerName: scope.resourceNameFormatter.format(props.loadBalancerName, props.resourceNameOptions),
129
129
  runtimePlatform: {
130
130
  cpuArchitecture: props.runtimePlatform?.cpuArchitecture ?? aws_ecs_1.CpuArchitecture.X86_64,
131
131
  operatingSystemFamily: props.runtimePlatform?.operatingSystemFamily ?? aws_ecs_1.OperatingSystemFamily.LINUX,
132
132
  },
133
- serviceName: scope.resourceNameFormatter(props.serviceName, props.resourceNameOptions),
133
+ serviceName: scope.resourceNameFormatter.format(props.serviceName, props.resourceNameOptions),
134
134
  taskImageOptions: {
135
135
  ...props.taskImageOptions,
136
136
  enableLogging: props.taskImageOptions?.enableLogging ?? true,
@@ -52,7 +52,7 @@ class EfsManager {
52
52
  const fileSystemId = props.provisionNewOnDeployment ? `${id}-${new Date().getMilliseconds()}` : `${id}`;
53
53
  const fileSystem = new aws_efs_1.FileSystem(scope, `${fileSystemId}`, {
54
54
  ...props,
55
- fileSystemName: scope.resourceNameFormatter(props.fileSystemName, props.resourceNameOptions),
55
+ fileSystemName: scope.resourceNameFormatter.format(props.fileSystemName, props.resourceNameOptions),
56
56
  lifecyclePolicy: props.lifecyclePolicy ?? aws_efs_1.LifecyclePolicy.AFTER_7_DAYS,
57
57
  outOfInfrequentAccessPolicy: props.outOfInfrequentAccessPolicy ?? aws_efs_1.OutOfInfrequentAccessPolicy.AFTER_1_ACCESS,
58
58
  performanceMode: props.performanceMode ?? aws_efs_1.PerformanceMode.GENERAL_PURPOSE,
@@ -73,7 +73,7 @@ class EksManager {
73
73
  },
74
74
  };
75
75
  const cluster = new aws_eks_1.Cluster(scope, `${id}Cluster`, {
76
- clusterName: scope.resourceNameFormatter(props.clusterName, props.resourceNameOptions),
76
+ clusterName: scope.resourceNameFormatter.format(props.clusterName, props.resourceNameOptions),
77
77
  defaultCapacity: props.appCapacity,
78
78
  defaultCapacityInstance: aws_ec2_1.InstanceType.of(aws_ec2_1.InstanceClass.T3, aws_ec2_1.InstanceSize.LARGE),
79
79
  version: aws_eks_1.KubernetesVersion.V1_27,
@@ -56,7 +56,7 @@ class ElastiCacheManager {
56
56
  const elasticacheCluster = new aws_elasticache_1.CfnCacheCluster(scope, `${id}`, {
57
57
  ...props,
58
58
  cacheSubnetGroupName: subnetGroup.cacheSubnetGroupName,
59
- clusterName: scope.resourceNameFormatter(props.clusterName, props.resourceNameOptions),
59
+ clusterName: scope.resourceNameFormatter.format(props.clusterName, props.resourceNameOptions),
60
60
  logDeliveryConfigurations,
61
61
  vpcSecurityGroupIds: securityGroupIds,
62
62
  });
@@ -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.format(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);
@@ -63,7 +67,7 @@ class EventManager {
63
67
  const rule = new aws_events_1.Rule(scope, `${id}`, {
64
68
  ...props,
65
69
  eventBus,
66
- ruleName: scope.resourceNameFormatter(props.ruleName, props.resourceNameOptions),
70
+ ruleName: scope.resourceNameFormatter.format(props.ruleName, props.resourceNameOptions),
67
71
  });
68
72
  if (targets && !lodash_1.default.isEmpty(targets)) {
69
73
  lodash_1.default.forEach(targets, target => {
@@ -99,12 +103,12 @@ class EventManager {
99
103
  description: 'Rule to send notification to lambda function target',
100
104
  eventBusName,
101
105
  eventPattern,
102
- name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
106
+ name: scope.resourceNameFormatter.format(props.name, props.resourceNameOptions),
103
107
  scheduleExpression,
104
108
  targets: [
105
109
  {
106
110
  arn: lambdaFunction.functionArn,
107
- id: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
111
+ id: scope.resourceNameFormatter.format(props.name, props.resourceNameOptions),
108
112
  input: props.input ?? undefined,
109
113
  },
110
114
  ],
@@ -144,7 +148,7 @@ class EventManager {
144
148
  ...props,
145
149
  description: 'Rule to send notification on new objects in data bucket to ecs task target',
146
150
  eventPattern,
147
- name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
151
+ name: scope.resourceNameFormatter.format(props.name, props.resourceNameOptions),
148
152
  targets: [
149
153
  {
150
154
  arn: cluster.clusterArn,
@@ -156,7 +160,7 @@ class EventManager {
156
160
  taskCount: 1,
157
161
  taskDefinitionArn: task.taskDefinitionArn,
158
162
  },
159
- id: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
163
+ id: scope.resourceNameFormatter.format(props.name, props.resourceNameOptions),
160
164
  roleArn: role instanceof aws_iam_1.Role ? role.roleArn : role.attrArn,
161
165
  },
162
166
  ],
@@ -181,7 +185,7 @@ class EventManager {
181
185
  const pipeRole = scope.iamManager.createRoleForSqsToSfnPipe(`${id}-role`, scope, sourceQueue.queueArn, targetStepFunction.stateMachineArn);
182
186
  const pipe = new aws_pipes_1.CfnPipe(scope, `${id}`, {
183
187
  ...props,
184
- name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
188
+ name: scope.resourceNameFormatter.format(props.name, props.resourceNameOptions),
185
189
  roleArn: pipeRole.roleArn,
186
190
  source: sourceQueue.queueArn,
187
191
  sourceParameters: {
@@ -227,7 +231,7 @@ class EventManager {
227
231
  const pipeRole = scope.iamManager.createRoleForSqsToLambdaPipe(`${id}-role`, scope, sourceQueue.queueArn, targetLambdaFunction.functionArn);
228
232
  const pipe = new aws_pipes_1.CfnPipe(scope, `${id}`, {
229
233
  ...props,
230
- name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
234
+ name: scope.resourceNameFormatter.format(props.name, props.resourceNameOptions),
231
235
  roleArn: pipeRole.roleArn,
232
236
  source: sourceQueue.queueArn,
233
237
  sourceParameters: {
@@ -270,7 +274,7 @@ class EventManager {
270
274
  const pipeRole = scope.iamManager.createRoleForDynamoDbToLambdaPipe(`${id}-role`, scope, sourceDynamoDbStreamArn, targetLambdaFunction.functionArn);
271
275
  const pipe = new aws_pipes_1.CfnPipe(scope, `${id}`, {
272
276
  ...props,
273
- name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
277
+ name: scope.resourceNameFormatter.format(props.name, props.resourceNameOptions),
274
278
  roleArn: pipeRole.roleArn,
275
279
  source: sourceDynamoDbStreamArn,
276
280
  sourceParameters: {
@@ -34,7 +34,7 @@ class EvidentlyManager {
34
34
  const project = new aws_evidently_1.CfnProject(scope, `${id}`, {
35
35
  ...props,
36
36
  description: `${props.description} ${scope.props.stage}`,
37
- name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
37
+ name: scope.resourceNameFormatter.format(props.name, props.resourceNameOptions),
38
38
  });
39
39
  (0, utils_1.createCfnOutput)(`${id}-projectArn`, scope, project.attrArn);
40
40
  (0, utils_1.createCfnOutput)(`${id}-projectName`, scope, project.name);
@@ -68,7 +68,7 @@ class EvidentlyManager {
68
68
  const launch = new aws_evidently_1.CfnLaunch(scope, `${id}`, {
69
69
  ...props,
70
70
  description: `${props.description} ${scope.props.stage}`,
71
- name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
71
+ name: scope.resourceNameFormatter.format(props.name, props.resourceNameOptions),
72
72
  });
73
73
  (0, utils_1.createCfnOutput)(`${id}-launchArn`, scope, launch.attrArn);
74
74
  (0, utils_1.createCfnOutput)(`${id}-launchName`, scope, launch.name);
@@ -88,7 +88,7 @@ class EvidentlyManager {
88
88
  const experiment = new aws_evidently_1.CfnExperiment(scope, `${id}`, {
89
89
  ...props,
90
90
  description: `${props.description} ${scope.props.stage}`,
91
- name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
91
+ name: scope.resourceNameFormatter.format(props.name, props.resourceNameOptions),
92
92
  });
93
93
  (0, utils_1.createCfnOutput)(`${id}-experimentArn`, scope, experiment.attrArn);
94
94
  (0, utils_1.createCfnOutput)(`${id}-experimentName`, scope, experiment.name);
@@ -108,7 +108,7 @@ class EvidentlyManager {
108
108
  const segment = new aws_evidently_1.CfnSegment(scope, `${id}`, {
109
109
  ...props,
110
110
  description: `${props.description} ${scope.props.stage}`,
111
- name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
111
+ name: scope.resourceNameFormatter.format(props.name, props.resourceNameOptions),
112
112
  });
113
113
  (0, utils_1.createCfnOutput)(`${id}-segmentArn`, scope, segment.attrArn);
114
114
  (0, utils_1.createCfnOutput)(`${id}-segmentName`, scope, segment.name);