@gradientedge/cdk-utils 9.10.1 → 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 +4 -4
  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 +9 -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 +1 -1
  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 +4 -4
  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 +9 -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
@@ -76,7 +76,7 @@ class LambdaManager {
76
76
  throw `Lambda props undefined for ${id}`;
77
77
  if (!props.functionName)
78
78
  throw `Lambda functionName undefined for ${id}`;
79
- const functionName = scope.resourceNameFormatter(props.functionName, props.resourceNameOptions);
79
+ const functionName = scope.resourceNameFormatter.format(props.functionName, props.resourceNameOptions);
80
80
  let deadLetterQueue;
81
81
  if (props.deadLetterQueueEnabled) {
82
82
  const redriveQueue = scope.sqsManager.createRedriveQueueForLambda(`${id}-rdq`, scope, props);
@@ -181,7 +181,7 @@ class LambdaManager {
181
181
  throw `Lambda props undefined for ${id}`;
182
182
  if (!props.functionName)
183
183
  throw `Lambda functionName undefined for ${id}`;
184
- const functionName = scope.resourceNameFormatter(props.functionName, props.resourceNameOptions);
184
+ const functionName = scope.resourceNameFormatter.format(props.functionName, props.resourceNameOptions);
185
185
  let deadLetterQueue;
186
186
  if (props.deadLetterQueueEnabled) {
187
187
  const redriveQueue = scope.sqsManager.createRedriveQueueForLambda(`${id}-rdq`, scope, props);
@@ -35,7 +35,7 @@ class SecretsManager {
35
35
  throw `Secret name undefined for ${id}`;
36
36
  const secret = new aws_secretsmanager_1.Secret(scope, `${id}`, {
37
37
  ...props,
38
- secretName: scope.resourceNameFormatter(props.secretName, props.resourceNameOptions),
38
+ secretName: scope.resourceNameFormatter.format(props.secretName, props.resourceNameOptions),
39
39
  });
40
40
  (0, utils_1.createCfnOutput)(`${id}-secretName`, scope, secret.secretName);
41
41
  (0, utils_1.createCfnOutput)(`${id}-secretArn`, scope, secret.secretArn);
@@ -39,8 +39,8 @@ class SnsManager {
39
39
  throw `Subscription topicName undefined for ${id}`;
40
40
  const topic = new aws_sns_1.Topic(scope, id, {
41
41
  ...props,
42
- displayName: scope.resourceNameFormatter(props.topicName, props.resourceNameOptions),
43
- topicName: scope.resourceNameFormatter(props.topicName, props.resourceNameOptions),
42
+ displayName: scope.resourceNameFormatter.format(props.topicName, props.resourceNameOptions),
43
+ topicName: scope.resourceNameFormatter.format(props.topicName, props.resourceNameOptions),
44
44
  });
45
45
  if (emails && !lodash_1.default.isEmpty(emails)) {
46
46
  lodash_1.default.forEach(emails, (email) => topic.addSubscription(new aws_sns_subscriptions_1.EmailSubscription(email)));
@@ -63,8 +63,8 @@ class SnsManager {
63
63
  throw `Subscription topicName undefined for ${id}`;
64
64
  const topic = new aws_sns_1.Topic(scope, id, {
65
65
  ...props,
66
- displayName: scope.resourceNameFormatter(props.topicName, props.resourceNameOptions),
67
- topicName: scope.resourceNameFormatter(props.topicName, props.resourceNameOptions),
66
+ displayName: scope.resourceNameFormatter.format(props.topicName, props.resourceNameOptions),
67
+ topicName: scope.resourceNameFormatter.format(props.topicName, props.resourceNameOptions),
68
68
  });
69
69
  topic.addSubscription(new aws_sns_subscriptions_1.LambdaSubscription(lambdaFunction));
70
70
  (0, utils_1.createCfnOutput)(`${id}-subscriptionArn`, scope, topic.topicArn);
@@ -37,7 +37,7 @@ class SqsManager {
37
37
  throw `Queue props undefined for ${id}`;
38
38
  if (!props.queueName)
39
39
  throw `Queue queueName undefined for ${id}`;
40
- let queueName = scope.resourceNameFormatter(props.queueName, props.resourceNameOptions);
40
+ let queueName = scope.resourceNameFormatter.format(props.queueName, props.resourceNameOptions);
41
41
  if (props.fifo)
42
42
  queueName += '.fifo';
43
43
  const queue = new aws_sqs_1.Queue(scope, id, {
@@ -76,7 +76,7 @@ class S3Manager {
76
76
  if (!scope.props.excludeAccountNumberForBuckets) {
77
77
  return S3Manager.determineBucketNameByAccountAndRegion(scope, bucketName);
78
78
  }
79
- return scope.resourceNameFormatter(bucketName, props.resourceNameOptions);
79
+ return scope.resourceNameFormatter.format(bucketName, props.resourceNameOptions);
80
80
  }
81
81
  /**
82
82
  * @summary Method to create a s3 bucket
@@ -377,7 +377,7 @@ class SfnManager {
377
377
  level: props.logs?.level ?? aws_stepfunctions_1.LogLevel.ALL,
378
378
  },
379
379
  role,
380
- stateMachineName: scope.resourceNameFormatter(props.stateMachineName, props.resourceNameOptions),
380
+ stateMachineName: scope.resourceNameFormatter.format(props.stateMachineName, props.resourceNameOptions),
381
381
  });
382
382
  (0, utils_1.createCfnOutput)(`${id}-stateMachineName`, scope, stateMachine.stateMachineName);
383
383
  (0, utils_1.createCfnOutput)(`${id}-stateMachineArn`, scope, stateMachine.stateMachineArn);
@@ -40,7 +40,7 @@ class VpcManager {
40
40
  throw `Vpc props undefined for ${id}`;
41
41
  if (!props.vpcName)
42
42
  throw `Vpc vpcName undefined for ${id}`;
43
- const vpcName = scope.resourceNameFormatter(props.vpcName, props.resourceNameOptions);
43
+ const vpcName = scope.resourceNameFormatter.format(props.vpcName, props.resourceNameOptions);
44
44
  let vpc;
45
45
  if (props.isIPV6) {
46
46
  vpc = new ipv6_1.Ipv6Vpc(scope, `${id}`, {
@@ -82,9 +82,9 @@ class VpcManager {
82
82
  * @param vpcIdentifier optional identifier for VPC
83
83
  */
84
84
  retrieveCommonVpc(id, scope, vpcIdentifier) {
85
- const vpcName = scope.resourceNameFormatter(vpcIdentifier ?? CommonVpcIdentifier);
85
+ const vpcName = scope.resourceNameFormatter.format(vpcIdentifier ?? CommonVpcIdentifier);
86
86
  return aws_ec2_1.Vpc.fromLookup(scope, `${id}`, {
87
- vpcName: scope.resourceNameFormatter(vpcIdentifier ?? CommonVpcIdentifier),
87
+ vpcName: scope.resourceNameFormatter.format(vpcIdentifier ?? CommonVpcIdentifier),
88
88
  });
89
89
  }
90
90
  }
@@ -34,7 +34,7 @@ class WafManager {
34
34
  const ipSet = new aws_wafv2_1.CfnIPSet(scope, `${id}`, {
35
35
  ...props,
36
36
  description: `IP Set for ${id} - ${scope.props.stage} 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}-ipSetId`, scope, ipSet.attrId);
40
40
  (0, utils_1.createCfnOutput)(`${id}-ipSetArn`, scope, ipSet.attrArn);
@@ -54,7 +54,7 @@ class WafManager {
54
54
  const webAcl = new aws_wafv2_1.CfnWebACL(scope, `${id}`, {
55
55
  ...props,
56
56
  description: `Web Acl for ${id} - ${scope.props.stage} stage`,
57
- name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
57
+ name: scope.resourceNameFormatter.format(props.name, props.resourceNameOptions),
58
58
  tags: [{ key: 'service', value: scope.props.name }],
59
59
  });
60
60
  (0, utils_1.createCfnOutput)(`${id}-webAclId`, scope, webAcl.attrId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "9.10.1",
3
+ "version": "9.11.0",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -33,7 +33,8 @@ import {
33
33
  WafManager,
34
34
  } from '../services'
35
35
  import { createCfnOutput } from '../utils'
36
- import { CommonStackProps, ResourceNameFormatterProps } from './types'
36
+ import { ResourceNameFormatter } from './resource-name-formatter'
37
+ import { CommonStackProps } from './types'
37
38
 
38
39
  /**
39
40
  * @subcategory Construct
@@ -50,6 +51,7 @@ import { CommonStackProps, ResourceNameFormatterProps } from './types'
50
51
  */
51
52
  export class CommonConstruct extends Construct {
52
53
  props: CommonStackProps
54
+ resourceNameFormatter: ResourceNameFormatter
53
55
  acmManager: AcmManager
54
56
  apiManager: ApiManager
55
57
  appConfigManager: AppConfigManager
@@ -85,6 +87,7 @@ export class CommonConstruct extends Construct {
85
87
  constructor(parent: Construct, id: string, props: CommonStackProps) {
86
88
  super(parent, id)
87
89
  this.props = props
90
+ this.resourceNameFormatter = new ResourceNameFormatter(this, `${id}-rnf`, props)
88
91
  this.acmManager = new AcmManager()
89
92
  this.apiManager = new ApiManager()
90
93
  this.appConfigManager = new AppConfigManager()
@@ -118,21 +121,6 @@ export class CommonConstruct extends Construct {
118
121
  this.determineFullyQualifiedDomain()
119
122
  }
120
123
 
121
- /**
122
- * @summary Helper method to format a resource name based on the provided options
123
- * @param resourceName the resource name to format
124
- * @param options options to control the formatting of the resource name
125
- * @returns The formatted resource name
126
- */
127
- public resourceNameFormatter(resourceName: string, options?: ResourceNameFormatterProps) {
128
- const resourceNameElements = []
129
- resourceNameElements.push(options?.prefix ?? this.props.resourcePrefix)
130
- resourceNameElements.push(resourceName)
131
- resourceNameElements.push(options?.suffix ?? this.props.resourceSuffix)
132
- resourceNameElements.push(this.props.stage)
133
- return resourceNameElements.filter(resourceNameElement => resourceNameElement != undefined).join('-')
134
- }
135
-
136
124
  /**
137
125
  * @summary Helper method to add CloudFormation outputs from the construct
138
126
  * @param id scoped id of the resource
@@ -0,0 +1,26 @@
1
+ import { Construct } from 'constructs'
2
+ import { CommonStackProps, ResourceNameFormatterProps } from './types'
3
+
4
+ export class ResourceNameFormatter extends Construct {
5
+ props: CommonStackProps
6
+
7
+ constructor(parent: Construct, id: string, props: CommonStackProps) {
8
+ super(parent, id)
9
+ this.props = props
10
+ }
11
+
12
+ /**
13
+ * @summary Helper method to format a resource name based on the provided options
14
+ * @param resourceName the resource name to format
15
+ * @param options options to control the formatting of the resource name
16
+ * @returns The formatted resource name
17
+ */
18
+ public format(resourceName: string, options?: ResourceNameFormatterProps) {
19
+ const resourceNameElements = []
20
+ resourceNameElements.push(options?.prefix ?? this.props.resourcePrefix)
21
+ resourceNameElements.push(resourceName)
22
+ resourceNameElements.push(options?.suffix ?? this.props.resourceSuffix)
23
+ resourceNameElements.push(this.props.stage)
24
+ return resourceNameElements.filter(resourceNameElement => resourceNameElement != undefined).join('-')
25
+ }
26
+ }
@@ -154,7 +154,7 @@ export class ApiToAnyTarget extends CommonConstruct {
154
154
  types: [this.isProductionStage() ? EndpointType.EDGE : EndpointType.REGIONAL],
155
155
  },
156
156
  ...this.props.api.restApi,
157
- restApiName: this.resourceNameFormatter(
157
+ restApiName: this.resourceNameFormatter.format(
158
158
  this.props.api.restApi?.restApiName,
159
159
  this.props.api.restApi?.resourceNameOptions
160
160
  ),
@@ -159,7 +159,7 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
159
159
  this.apiEvent.eventBus = EventBus.fromEventBusName(
160
160
  this,
161
161
  `${this.id}-event-bus`,
162
- this.resourceNameFormatter(this.props.event.eventBusName ?? 'default')
162
+ this.resourceNameFormatter.format(this.props.event.eventBusName ?? 'default')
163
163
  )
164
164
  return
165
165
  }
@@ -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.resourceNameFormatter(this.id)}/events/api-to-eventbridge-target`,
178
+ logGroupName: `/${this.resourceNameFormatter.format(this.id)}/events/api-to-eventbridge-target`,
179
179
  },
180
180
  ...this.props.event.logGroup,
181
181
  })
@@ -356,7 +356,7 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
356
356
  `${this.id}-rest-api-access-log`,
357
357
  this,
358
358
  {
359
- logGroupName: `/custom/api/${this.resourceNameFormatter(this.id)}-rest-api-access`,
359
+ logGroupName: `/custom/api/${this.resourceNameFormatter.format(this.id)}-rest-api-access`,
360
360
  removalPolicy: RemovalPolicy.DESTROY,
361
361
  }
362
362
  )
@@ -406,7 +406,7 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
406
406
  types: [EndpointType.REGIONAL],
407
407
  },
408
408
  ...this.props.api.restApi,
409
- restApiName: this.resourceNameFormatter(
409
+ restApiName: this.resourceNameFormatter.format(
410
410
  this.props.api.restApi?.restApiName,
411
411
  this.props.api.restApi?.resourceNameOptions
412
412
  ),
@@ -362,7 +362,7 @@ export class ApiToEventBridgeTargetWithSns extends CommonConstruct {
362
362
  `${this.id}-destined-topic`,
363
363
  this,
364
364
  {
365
- topicName: this.resourceNameFormatter(`${this.id}-destined-topic`),
365
+ topicName: this.resourceNameFormatter.format(`${this.id}-destined-topic`),
366
366
  },
367
367
  this.apiDestinedLambda.function
368
368
  )
@@ -538,7 +538,7 @@ export class ApiToEventBridgeTargetWithSns extends CommonConstruct {
538
538
  types: [EndpointType.REGIONAL],
539
539
  },
540
540
  ...this.props.api,
541
- restApiName: this.resourceNameFormatter(
541
+ restApiName: this.resourceNameFormatter.format(
542
542
  this.props.api.restApi?.restApiName,
543
543
  this.props.api.restApi?.resourceNameOptions
544
544
  ),
@@ -138,7 +138,7 @@ export class ApiToLambdaTarget extends CommonConstruct {
138
138
  this.apiToLambdaTargetRestApi.lambda = Function.fromFunctionName(
139
139
  this,
140
140
  `${this.id}-lambda`,
141
- this.resourceNameFormatter(this.props.lambdaFunctionName)
141
+ this.resourceNameFormatter.format(this.props.lambdaFunctionName)
142
142
  )
143
143
  }
144
144
 
@@ -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.resourceNameFormatter(this.id)}-rest-api-access`,
159
+ logGroupName: `/custom/api/${this.resourceNameFormatter.format(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.resourceNameFormatter(this.props.appConfig.deploymentStrategy.name),
82
+ name: this.resourceNameFormatter.format(this.props.appConfig.deploymentStrategy.name),
83
83
  replicateTo: this.props.appConfig.deploymentStrategy.replicateTo,
84
84
  })
85
85
  }
@@ -187,11 +187,11 @@ export class LambdaWithIamAccess extends CommonConstruct {
187
187
  */
188
188
  protected createIamUserForLambdaFunction() {
189
189
  this.lambdaIamUser = new User(this, `${this.id}-lambda-user`, {
190
- userName: this.resourceNameFormatter(`${this.id}-user`),
190
+ userName: this.resourceNameFormatter.format(`${this.id}-user`),
191
191
  })
192
192
 
193
193
  new Policy(this, `${this.id}-lambda-user-policy`, {
194
- policyName: this.resourceNameFormatter(`${this.id}-policy`),
194
+ policyName: this.resourceNameFormatter.format(`${this.id}-policy`),
195
195
  statements: [
196
196
  new PolicyStatement({
197
197
  actions: ['lambda:InvokeFunction'],
@@ -204,7 +204,7 @@ export class LambdaWithIamAccess extends CommonConstruct {
204
204
  if (this.props.lambda.lambdaAliases && !_.isEmpty(this.props.lambda.lambdaAliases)) {
205
205
  _.forEach(this.props.lambda.lambdaAliases, (alias, index) => {
206
206
  new Policy(this, `${this.id}-alias-user-policy`, {
207
- policyName: this.resourceNameFormatter(`${this.id}--alias-policy-${index}`),
207
+ policyName: this.resourceNameFormatter.format(`${this.id}--alias-policy-${index}`),
208
208
  statements: [
209
209
  new PolicyStatement({
210
210
  actions: ['lambda:InvokeFunction'],
@@ -296,11 +296,11 @@ export class SiteWithEcsBackend extends CommonConstruct {
296
296
  enableECSManagedTags: true,
297
297
  healthCheckGracePeriod: Duration.seconds(60),
298
298
  listenerPort: this.props.siteTask.listenerPort,
299
- loadBalancerName: this.resourceNameFormatter(this.props.siteTask.loadBalancerName ?? this.id),
299
+ loadBalancerName: this.resourceNameFormatter.format(this.props.siteTask.loadBalancerName ?? this.id),
300
300
  maxHealthyPercent: this.props.siteTask.maxHealthyPercent,
301
301
  memoryLimitMiB: this.props.siteTask.memoryLimitMiB,
302
302
  minHealthyPercent: this.props.siteTask.minHealthyPercent,
303
- serviceName: this.resourceNameFormatter(this.props.siteTask.serviceName ?? this.id),
303
+ serviceName: this.resourceNameFormatter.format(this.props.siteTask.serviceName ?? this.id),
304
304
  taskDefinition: this.props.siteTask.taskDefinition,
305
305
  taskImageOptions: {
306
306
  containerPort: this.props.siteTask.taskImageOptions?.containerPort,
@@ -400,7 +400,7 @@ export class SiteWithEcsBackend extends CommonConstruct {
400
400
  transitEncryption: this.props.siteFileSystem.transitEncryption,
401
401
  transitEncryptionPort: this.props.siteFileSystem.transitEncryptionPort,
402
402
  },
403
- name: this.resourceNameFormatter(this.props.siteFileSystem?.fileSystemName ?? this.id),
403
+ name: this.resourceNameFormatter.format(this.props.siteFileSystem?.fileSystemName ?? this.id),
404
404
  })
405
405
 
406
406
  if (this.props.siteTask.mountPoints && !_.isEmpty(this.props.siteTask.mountPoints)) {
@@ -408,7 +408,7 @@ export class SiteWithEcsBackend extends CommonConstruct {
408
408
  this.siteEcsTaskDefinition.defaultContainer?.addMountPoints({
409
409
  containerPath: mountPoint.containerPath,
410
410
  readOnly: mountPoint.readOnly,
411
- sourceVolume: this.resourceNameFormatter(this.props.siteFileSystem?.fileSystemName ?? this.id),
411
+ sourceVolume: this.resourceNameFormatter.format(this.props.siteFileSystem?.fileSystemName ?? this.id),
412
412
  })
413
413
  })
414
414
  }
@@ -431,7 +431,7 @@ export class SiteWithEcsBackend extends CommonConstruct {
431
431
  if (!siteCachePolicy.cachePolicyName) throw `SiteCachePolicy cachePolicyName undefined for ${id}`
432
432
 
433
433
  return new CachePolicy(this, `${id}`, {
434
- cachePolicyName: this.resourceNameFormatter(siteCachePolicy.cachePolicyName),
434
+ cachePolicyName: this.resourceNameFormatter.format(siteCachePolicy.cachePolicyName),
435
435
  comment: `Policy for ${this.id}-distribution - ${this.props.stage} stage`,
436
436
  cookieBehavior: siteCachePolicy.cookieBehavior,
437
437
  enableAcceptEncodingBrotli: siteCachePolicy.enableAcceptEncodingBrotli,
@@ -460,7 +460,9 @@ export class SiteWithEcsBackend extends CommonConstruct {
460
460
  comment: `Request Policy for ${this.id}-distribution - ${this.props.stage} stage`,
461
461
  cookieBehavior: this.props.siteOriginRequestPolicy.cookieBehavior,
462
462
  headerBehavior: this.props.siteOriginRequestPolicy.headerBehavior,
463
- originRequestPolicyName: this.resourceNameFormatter(this.props.siteOriginRequestPolicy.originRequestPolicyName),
463
+ originRequestPolicyName: this.resourceNameFormatter.format(
464
+ this.props.siteOriginRequestPolicy.originRequestPolicyName
465
+ ),
464
466
  queryStringBehavior: this.props.siteOriginRequestPolicy.queryStringBehavior,
465
467
  })
466
468
 
@@ -477,7 +479,7 @@ export class SiteWithEcsBackend extends CommonConstruct {
477
479
  return new ResponseHeadersPolicy(this, `${this.id}-${props.type}-srhp`, {
478
480
  ...props,
479
481
  comment: `Response Header Policy for ${props.type} for ${this.id}-distribution - ${this.props.stage} stage`,
480
- responseHeadersPolicyName: this.resourceNameFormatter(props.responseHeadersPolicyName),
482
+ responseHeadersPolicyName: this.resourceNameFormatter.format(props.responseHeadersPolicyName),
481
483
  securityHeadersBehavior: {
482
484
  ...props.securityHeadersBehavior,
483
485
  strictTransportSecurity: {
@@ -193,7 +193,7 @@ export class SiteWithLambdaBackend extends CommonConstruct {
193
193
  if (!siteCachePolicy.cachePolicyName) throw `SiteCachePolicy cachePolicyName undefined for ${id}`
194
194
 
195
195
  return new CachePolicy(this, `${id}`, {
196
- cachePolicyName: this.resourceNameFormatter(siteCachePolicy.cachePolicyName),
196
+ cachePolicyName: this.resourceNameFormatter.format(siteCachePolicy.cachePolicyName),
197
197
  comment: `Policy for ${this.id}-distribution - ${this.props.stage} stage`,
198
198
  cookieBehavior: siteCachePolicy.cookieBehavior,
199
199
  enableAcceptEncodingBrotli: siteCachePolicy.enableAcceptEncodingBrotli,
@@ -222,7 +222,9 @@ export class SiteWithLambdaBackend extends CommonConstruct {
222
222
  comment: `Request Policy for ${this.id}-distribution - ${this.props.stage} stage`,
223
223
  cookieBehavior: this.props.siteOriginRequestPolicy.cookieBehavior,
224
224
  headerBehavior: this.props.siteOriginRequestPolicy.headerBehavior,
225
- originRequestPolicyName: this.resourceNameFormatter(this.props.siteOriginRequestPolicy.originRequestPolicyName),
225
+ originRequestPolicyName: this.resourceNameFormatter.format(
226
+ this.props.siteOriginRequestPolicy.originRequestPolicyName
227
+ ),
226
228
  queryStringBehavior: this.props.siteOriginRequestPolicy.queryStringBehavior,
227
229
  })
228
230
 
@@ -239,7 +241,7 @@ export class SiteWithLambdaBackend extends CommonConstruct {
239
241
  return new ResponseHeadersPolicy(this, `${this.id}-${props.type}-srhp`, {
240
242
  ...props,
241
243
  comment: `Response Header Policy for ${props.type} for ${this.id}-distribution - ${this.props.stage} stage`,
242
- responseHeadersPolicyName: this.resourceNameFormatter(props.responseHeadersPolicyName),
244
+ responseHeadersPolicyName: this.resourceNameFormatter.format(props.responseHeadersPolicyName),
243
245
  securityHeadersBehavior: {
244
246
  ...props.securityHeadersBehavior,
245
247
  strictTransportSecurity: {
@@ -65,7 +65,7 @@ export class ApiManager {
65
65
  handler: lambdaFunction,
66
66
  minCompressionSize: props.minCompressionSizeInBytes ? Size.bytes(props.minCompressionSizeInBytes) : undefined,
67
67
  proxy: props.proxy ?? true,
68
- restApiName: scope.resourceNameFormatter(props.restApiName, props.resourceNameOptions),
68
+ restApiName: scope.resourceNameFormatter.format(props.restApiName, props.resourceNameOptions),
69
69
  })
70
70
 
71
71
  if (props.tags && !_.isEmpty(props.tags)) {
@@ -51,7 +51,7 @@ export class AppConfigManager {
51
51
 
52
52
  const application = new CfnApplication(scope, `${id}`, {
53
53
  ...props.application,
54
- name: scope.resourceNameFormatter(props.application.name, props.resourceNameOptions),
54
+ name: scope.resourceNameFormatter.format(props.application.name, props.resourceNameOptions),
55
55
  })
56
56
 
57
57
  createCfnOutput(`${id}-ApplicationId`, scope, Fn.ref(application.logicalId))
@@ -109,7 +109,7 @@ export class AppConfigManager {
109
109
  ...props.configurationProfile,
110
110
  applicationId,
111
111
  locationUri: props.configurationProfile.locationUri || 'hosted',
112
- name: scope.resourceNameFormatter(props.configurationProfile.name, props.resourceNameOptions),
112
+ name: scope.resourceNameFormatter.format(props.configurationProfile.name, props.resourceNameOptions),
113
113
  })
114
114
 
115
115
  createCfnOutput(`${id}-configurationProfileId`, scope, Fn.ref(profile.logicalId))
@@ -284,7 +284,7 @@ export class CloudFrontManager {
284
284
  ...environment,
285
285
  },
286
286
  filesystem: accessPoint ? FileSystem.fromEfsAccessPoint(accessPoint, mountPath ?? '/mnt/msg') : undefined,
287
- functionName: scope.resourceNameFormatter(props.functionName, props.resourceNameOptions),
287
+ functionName: scope.resourceNameFormatter.format(props.functionName, props.resourceNameOptions),
288
288
  handler: props.handler ?? 'index.handler',
289
289
  layers: layers,
290
290
  logRetention: props.logRetention,
@@ -360,7 +360,7 @@ export class CloudFrontManager {
360
360
  filePath: props.functionFilePath,
361
361
  }),
362
362
  comment: props.comment,
363
- functionName: scope.resourceNameFormatter(props.functionName, props.resourceNameOptions),
363
+ functionName: scope.resourceNameFormatter.format(props.functionName, props.resourceNameOptions),
364
364
  })
365
365
 
366
366
  createCfnOutput(`${id}-functionArn`, scope, cloudfrontFunction.functionArn)
@@ -72,7 +72,7 @@ export class CloudTrailManager {
72
72
  s3BucketName: logBucket.bucketName,
73
73
  s3KeyPrefix: `logs-${props.trailName}`,
74
74
  tags: [{ key: 'service', value: scope.props.name }],
75
- trailName: scope.resourceNameFormatter(props.trailName, props.resourceNameOptions),
75
+ trailName: scope.resourceNameFormatter.format(props.trailName, props.resourceNameOptions),
76
76
  })
77
77
 
78
78
  cloudTrail.addDependency(logBucketPolicy)
@@ -60,7 +60,7 @@ export class DynamodbManager {
60
60
 
61
61
  const table = new 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
 
66
66
  createCfnOutput(`${id}-tableName`, scope, table.tableName)
@@ -159,12 +159,12 @@ export class EcsManager {
159
159
  cluster,
160
160
  enableECSManagedTags: true,
161
161
  healthCheckGracePeriod: props.healthCheckGracePeriod ?? Duration.seconds(60),
162
- loadBalancerName: scope.resourceNameFormatter(props.loadBalancerName, props.resourceNameOptions),
162
+ loadBalancerName: scope.resourceNameFormatter.format(props.loadBalancerName, props.resourceNameOptions),
163
163
  runtimePlatform: {
164
164
  cpuArchitecture: props.runtimePlatform?.cpuArchitecture ?? CpuArchitecture.X86_64,
165
165
  operatingSystemFamily: props.runtimePlatform?.operatingSystemFamily ?? OperatingSystemFamily.LINUX,
166
166
  },
167
- serviceName: scope.resourceNameFormatter(props.serviceName, props.resourceNameOptions),
167
+ serviceName: scope.resourceNameFormatter.format(props.serviceName, props.resourceNameOptions),
168
168
  taskImageOptions: {
169
169
  ...props.taskImageOptions,
170
170
  enableLogging: props.taskImageOptions?.enableLogging ?? true,
@@ -59,7 +59,7 @@ export class EfsManager {
59
59
  const fileSystemId = props.provisionNewOnDeployment ? `${id}-${new Date().getMilliseconds()}` : `${id}`
60
60
  const fileSystem = new FileSystem(scope, `${fileSystemId}`, {
61
61
  ...props,
62
- fileSystemName: scope.resourceNameFormatter(props.fileSystemName, props.resourceNameOptions),
62
+ fileSystemName: scope.resourceNameFormatter.format(props.fileSystemName, props.resourceNameOptions),
63
63
  lifecyclePolicy: props.lifecyclePolicy ?? LifecyclePolicy.AFTER_7_DAYS,
64
64
  outOfInfrequentAccessPolicy: props.outOfInfrequentAccessPolicy ?? OutOfInfrequentAccessPolicy.AFTER_1_ACCESS,
65
65
  performanceMode: props.performanceMode ?? PerformanceMode.GENERAL_PURPOSE,
@@ -82,7 +82,7 @@ export class EksManager {
82
82
  }
83
83
 
84
84
  const cluster = new Cluster(scope, `${id}Cluster`, {
85
- clusterName: scope.resourceNameFormatter(props.clusterName, props.resourceNameOptions),
85
+ clusterName: scope.resourceNameFormatter.format(props.clusterName, props.resourceNameOptions),
86
86
  defaultCapacity: props.appCapacity,
87
87
  defaultCapacityInstance: InstanceType.of(InstanceClass.T3, InstanceSize.LARGE),
88
88
  version: KubernetesVersion.V1_27,
@@ -61,7 +61,7 @@ export class ElastiCacheManager {
61
61
  const elasticacheCluster = new CfnCacheCluster(scope, `${id}`, {
62
62
  ...props,
63
63
  cacheSubnetGroupName: subnetGroup.cacheSubnetGroupName,
64
- clusterName: scope.resourceNameFormatter(props.clusterName, props.resourceNameOptions),
64
+ clusterName: scope.resourceNameFormatter.format(props.clusterName, props.resourceNameOptions),
65
65
  logDeliveryConfigurations,
66
66
  vpcSecurityGroupIds: securityGroupIds,
67
67
  })
@@ -47,7 +47,7 @@ export class EventManager {
47
47
 
48
48
  let eventBusName = props.eventBusName
49
49
  if (eventBusName && eventBusName != 'default') {
50
- eventBusName = scope.resourceNameFormatter(props.eventBusName, props.resourceNameOptions)
50
+ eventBusName = scope.resourceNameFormatter.format(props.eventBusName, props.resourceNameOptions)
51
51
  }
52
52
  const eventBus = new EventBus(scope, `${id}`, {
53
53
  ...props,
@@ -81,7 +81,7 @@ export class EventManager {
81
81
  const rule = new Rule(scope, `${id}`, {
82
82
  ...props,
83
83
  eventBus,
84
- ruleName: scope.resourceNameFormatter(props.ruleName, props.resourceNameOptions),
84
+ ruleName: scope.resourceNameFormatter.format(props.ruleName, props.resourceNameOptions),
85
85
  })
86
86
 
87
87
  if (targets && !_.isEmpty(targets)) {
@@ -129,12 +129,12 @@ export class EventManager {
129
129
  description: 'Rule to send notification to lambda function target',
130
130
  eventBusName,
131
131
  eventPattern,
132
- name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
132
+ name: scope.resourceNameFormatter.format(props.name, props.resourceNameOptions),
133
133
  scheduleExpression,
134
134
  targets: [
135
135
  {
136
136
  arn: lambdaFunction.functionArn,
137
- id: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
137
+ id: scope.resourceNameFormatter.format(props.name, props.resourceNameOptions),
138
138
  input: props.input ?? undefined,
139
139
  },
140
140
  ],
@@ -187,7 +187,7 @@ export class EventManager {
187
187
  ...props,
188
188
  description: 'Rule to send notification on new objects in data bucket to ecs task target',
189
189
  eventPattern,
190
- name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
190
+ name: scope.resourceNameFormatter.format(props.name, props.resourceNameOptions),
191
191
  targets: [
192
192
  {
193
193
  arn: cluster.clusterArn,
@@ -199,7 +199,7 @@ export class EventManager {
199
199
  taskCount: 1,
200
200
  taskDefinitionArn: task.taskDefinitionArn,
201
201
  },
202
- id: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
202
+ id: scope.resourceNameFormatter.format(props.name, props.resourceNameOptions),
203
203
  roleArn: role instanceof Role ? role.roleArn : role.attrArn,
204
204
  },
205
205
  ],
@@ -238,7 +238,7 @@ export class EventManager {
238
238
 
239
239
  const pipe = new CfnPipe(scope, `${id}`, {
240
240
  ...props,
241
- name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
241
+ name: scope.resourceNameFormatter.format(props.name, props.resourceNameOptions),
242
242
  roleArn: pipeRole.roleArn,
243
243
  source: sourceQueue.queueArn,
244
244
  sourceParameters: {
@@ -298,7 +298,7 @@ export class EventManager {
298
298
 
299
299
  const pipe = new CfnPipe(scope, `${id}`, {
300
300
  ...props,
301
- name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
301
+ name: scope.resourceNameFormatter.format(props.name, props.resourceNameOptions),
302
302
  roleArn: pipeRole.roleArn,
303
303
  source: sourceQueue.queueArn,
304
304
  sourceParameters: {
@@ -355,7 +355,7 @@ export class EventManager {
355
355
 
356
356
  const pipe = new CfnPipe(scope, `${id}`, {
357
357
  ...props,
358
- name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
358
+ name: scope.resourceNameFormatter.format(props.name, props.resourceNameOptions),
359
359
  roleArn: pipeRole.roleArn,
360
360
  source: sourceDynamoDbStreamArn,
361
361
  sourceParameters: {
@@ -39,7 +39,7 @@ export class EvidentlyManager {
39
39
  const project = new CfnProject(scope, `${id}`, {
40
40
  ...props,
41
41
  description: `${props.description} ${scope.props.stage}`,
42
- name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
42
+ name: scope.resourceNameFormatter.format(props.name, props.resourceNameOptions),
43
43
  })
44
44
  createCfnOutput(`${id}-projectArn`, scope, project.attrArn)
45
45
  createCfnOutput(`${id}-projectName`, scope, project.name)
@@ -74,7 +74,7 @@ export class EvidentlyManager {
74
74
  const launch = new CfnLaunch(scope, `${id}`, {
75
75
  ...props,
76
76
  description: `${props.description} ${scope.props.stage}`,
77
- name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
77
+ name: scope.resourceNameFormatter.format(props.name, props.resourceNameOptions),
78
78
  })
79
79
  createCfnOutput(`${id}-launchArn`, scope, launch.attrArn)
80
80
  createCfnOutput(`${id}-launchName`, scope, launch.name)
@@ -94,7 +94,7 @@ export class EvidentlyManager {
94
94
  const experiment = new CfnExperiment(scope, `${id}`, {
95
95
  ...props,
96
96
  description: `${props.description} ${scope.props.stage}`,
97
- name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
97
+ name: scope.resourceNameFormatter.format(props.name, props.resourceNameOptions),
98
98
  })
99
99
  createCfnOutput(`${id}-experimentArn`, scope, experiment.attrArn)
100
100
  createCfnOutput(`${id}-experimentName`, scope, experiment.name)
@@ -114,7 +114,7 @@ export class EvidentlyManager {
114
114
  const segment = new CfnSegment(scope, `${id}`, {
115
115
  ...props,
116
116
  description: `${props.description} ${scope.props.stage}`,
117
- name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
117
+ name: scope.resourceNameFormatter.format(props.name, props.resourceNameOptions),
118
118
  })
119
119
  createCfnOutput(`${id}-segmentArn`, scope, segment.attrArn)
120
120
  createCfnOutput(`${id}-segmentName`, scope, segment.name)