@gradientedge/cdk-utils 9.9.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.
Files changed (113) hide show
  1. package/dist/src/lib/aws/common/construct.d.ts +8 -1
  2. package/dist/src/lib/aws/common/construct.js +14 -0
  3. package/dist/src/lib/aws/common/stack.d.ts +3 -0
  4. package/dist/src/lib/aws/common/stack.js +3 -0
  5. package/dist/src/lib/aws/common/types.d.ts +8 -0
  6. package/dist/src/lib/aws/construct/api-to-any-target/main.js +3 -1
  7. package/dist/src/lib/aws/construct/api-to-any-target/types.d.ts +3 -3
  8. package/dist/src/lib/aws/construct/api-to-eventbridge-target/main.js +9 -6
  9. package/dist/src/lib/aws/construct/api-to-eventbridge-target/types.d.ts +6 -6
  10. package/dist/src/lib/aws/construct/api-to-eventbridge-target-with-sns/main.js +4 -2
  11. package/dist/src/lib/aws/construct/api-to-lambda-target/main.js +2 -2
  12. package/dist/src/lib/aws/construct/application-configuration/main.js +1 -1
  13. package/dist/src/lib/aws/construct/lambda-with-iam-access/main.js +4 -5
  14. package/dist/src/lib/aws/construct/site-with-ecs-backend/main.js +13 -9
  15. package/dist/src/lib/aws/construct/site-with-lambda-backend/main.js +9 -3
  16. package/dist/src/lib/aws/services/api-gateway/main.js +3 -1
  17. package/dist/src/lib/aws/services/api-gateway/types.d.ts +6 -1
  18. package/dist/src/lib/aws/services/appconfig/main.js +2 -2
  19. package/dist/src/lib/aws/services/appconfig/types.d.ts +2 -0
  20. package/dist/src/lib/aws/services/cloudfront/main.js +8 -2
  21. package/dist/src/lib/aws/services/cloudfront/types.d.ts +2 -0
  22. package/dist/src/lib/aws/services/cloudtrail/main.js +3 -1
  23. package/dist/src/lib/aws/services/cloudtrail/types.d.ts +2 -0
  24. package/dist/src/lib/aws/services/dynamodb/main.js +3 -1
  25. package/dist/src/lib/aws/services/dynamodb/types.d.ts +2 -0
  26. package/dist/src/lib/aws/services/elastic-container-service/main.js +6 -2
  27. package/dist/src/lib/aws/services/elastic-container-service/types.d.ts +2 -0
  28. package/dist/src/lib/aws/services/elastic-file-system/main.js +3 -1
  29. package/dist/src/lib/aws/services/elastic-file-system/types.d.ts +3 -1
  30. package/dist/src/lib/aws/services/elastic-kubernetes-service/main.js +3 -1
  31. package/dist/src/lib/aws/services/elastic-kubernetes-service/types.d.ts +2 -0
  32. package/dist/src/lib/aws/services/elasticache/main.js +3 -1
  33. package/dist/src/lib/aws/services/elasticache/types.d.ts +2 -0
  34. package/dist/src/lib/aws/services/eventbridge/main.js +38 -9
  35. package/dist/src/lib/aws/services/eventbridge/types.d.ts +9 -1
  36. package/dist/src/lib/aws/services/evidently/main.js +22 -4
  37. package/dist/src/lib/aws/services/evidently/types.d.ts +5 -0
  38. package/dist/src/lib/aws/services/identity-access-management/main.js +10 -10
  39. package/dist/src/lib/aws/services/lambda/main.js +6 -2
  40. package/dist/src/lib/aws/services/lambda/types.d.ts +5 -2
  41. package/dist/src/lib/aws/services/secrets-manager/index.d.ts +1 -0
  42. package/dist/src/lib/aws/services/secrets-manager/index.js +1 -0
  43. package/dist/src/lib/aws/services/secrets-manager/main.d.ts +3 -2
  44. package/dist/src/lib/aws/services/secrets-manager/main.js +5 -1
  45. package/dist/src/lib/aws/services/secrets-manager/types.d.ts +5 -0
  46. package/dist/src/lib/aws/services/secrets-manager/types.js +2 -0
  47. package/dist/src/lib/aws/services/simple-notification-service/main.js +8 -4
  48. package/dist/src/lib/aws/services/simple-notification-service/types.d.ts +2 -0
  49. package/dist/src/lib/aws/services/simple-queue-service/main.js +9 -7
  50. package/dist/src/lib/aws/services/simple-queue-service/types.d.ts +2 -0
  51. package/dist/src/lib/aws/services/simple-storage-service/main.d.ts +1 -1
  52. package/dist/src/lib/aws/services/simple-storage-service/main.js +12 -8
  53. package/dist/src/lib/aws/services/simple-storage-service/types.d.ts +3 -1
  54. package/dist/src/lib/aws/services/step-function/main.js +3 -1
  55. package/dist/src/lib/aws/services/step-function/types.d.ts +2 -0
  56. package/dist/src/lib/aws/services/virtual-private-cloud/main.js +10 -3
  57. package/dist/src/lib/aws/services/virtual-private-cloud/types.d.ts +2 -0
  58. package/dist/src/lib/aws/services/web-application-firewall/main.js +6 -2
  59. package/dist/src/lib/aws/services/web-application-firewall/types.d.ts +3 -0
  60. package/package.json +2 -2
  61. package/src/lib/aws/common/construct.ts +16 -1
  62. package/src/lib/aws/common/stack.ts +3 -0
  63. package/src/lib/aws/common/types.ts +9 -0
  64. package/src/lib/aws/construct/api-to-any-target/main.ts +6 -1
  65. package/src/lib/aws/construct/api-to-any-target/types.ts +2 -3
  66. package/src/lib/aws/construct/api-to-eventbridge-target/main.ts +13 -6
  67. package/src/lib/aws/construct/api-to-eventbridge-target/types.ts +6 -7
  68. package/src/lib/aws/construct/api-to-eventbridge-target-with-sns/main.ts +7 -2
  69. package/src/lib/aws/construct/api-to-lambda-target/main.ts +2 -2
  70. package/src/lib/aws/construct/application-configuration/main.ts +1 -1
  71. package/src/lib/aws/construct/lambda-with-iam-access/main.ts +5 -5
  72. package/src/lib/aws/construct/site-with-ecs-backend/main.ts +15 -9
  73. package/src/lib/aws/construct/site-with-lambda-backend/main.ts +11 -3
  74. package/src/lib/aws/services/api-gateway/main.ts +3 -1
  75. package/src/lib/aws/services/api-gateway/types.ts +7 -1
  76. package/src/lib/aws/services/appconfig/main.ts +2 -2
  77. package/src/lib/aws/services/appconfig/types.ts +2 -0
  78. package/src/lib/aws/services/cloudfront/main.ts +6 -2
  79. package/src/lib/aws/services/cloudfront/types.ts +2 -0
  80. package/src/lib/aws/services/cloudtrail/main.ts +2 -1
  81. package/src/lib/aws/services/cloudtrail/types.ts +4 -1
  82. package/src/lib/aws/services/dynamodb/main.ts +2 -1
  83. package/src/lib/aws/services/dynamodb/types.ts +4 -1
  84. package/src/lib/aws/services/elastic-container-service/main.ts +4 -2
  85. package/src/lib/aws/services/elastic-container-service/types.ts +2 -0
  86. package/src/lib/aws/services/elastic-file-system/main.ts +2 -1
  87. package/src/lib/aws/services/elastic-file-system/types.ts +3 -1
  88. package/src/lib/aws/services/elastic-kubernetes-service/main.ts +2 -1
  89. package/src/lib/aws/services/elastic-kubernetes-service/types.ts +2 -0
  90. package/src/lib/aws/services/elasticache/main.ts +2 -1
  91. package/src/lib/aws/services/elasticache/types.ts +4 -1
  92. package/src/lib/aws/services/eventbridge/main.ts +32 -9
  93. package/src/lib/aws/services/eventbridge/types.ts +11 -2
  94. package/src/lib/aws/services/evidently/main.ts +18 -4
  95. package/src/lib/aws/services/evidently/types.ts +13 -4
  96. package/src/lib/aws/services/identity-access-management/main.ts +10 -10
  97. package/src/lib/aws/services/lambda/main.ts +4 -2
  98. package/src/lib/aws/services/lambda/types.ts +5 -2
  99. package/src/lib/aws/services/secrets-manager/index.ts +1 -0
  100. package/src/lib/aws/services/secrets-manager/main.ts +7 -3
  101. package/src/lib/aws/services/secrets-manager/types.ts +6 -0
  102. package/src/lib/aws/services/simple-notification-service/main.ts +6 -4
  103. package/src/lib/aws/services/simple-notification-service/types.ts +4 -1
  104. package/src/lib/aws/services/simple-queue-service/main.ts +8 -7
  105. package/src/lib/aws/services/simple-queue-service/types.ts +2 -0
  106. package/src/lib/aws/services/simple-storage-service/main.ts +12 -8
  107. package/src/lib/aws/services/simple-storage-service/types.ts +3 -1
  108. package/src/lib/aws/services/step-function/main.ts +3 -1
  109. package/src/lib/aws/services/step-function/types.ts +4 -1
  110. package/src/lib/aws/services/virtual-private-cloud/main.ts +9 -3
  111. package/src/lib/aws/services/virtual-private-cloud/types.ts +2 -0
  112. package/src/lib/aws/services/web-application-firewall/main.ts +4 -2
  113. package/src/lib/aws/services/web-application-firewall/types.ts +7 -2
@@ -190,8 +190,10 @@ export class SiteWithLambdaBackend extends CommonConstruct {
190
190
  }
191
191
 
192
192
  protected createSiteCachePolicy(id: string, siteCachePolicy: SiteWithLambdaBackendCachePolicyProps) {
193
+ if (!siteCachePolicy.cachePolicyName) throw `SiteCachePolicy cachePolicyName undefined for ${id}`
194
+
193
195
  return new CachePolicy(this, `${id}`, {
194
- cachePolicyName: `${this.id}-${siteCachePolicy.cachePolicyName}`,
196
+ cachePolicyName: this.resourceNameFormatter(siteCachePolicy.cachePolicyName),
195
197
  comment: `Policy for ${this.id}-distribution - ${this.props.stage} stage`,
196
198
  cookieBehavior: siteCachePolicy.cookieBehavior,
197
199
  enableAcceptEncodingBrotli: siteCachePolicy.enableAcceptEncodingBrotli,
@@ -213,11 +215,14 @@ export class SiteWithLambdaBackend extends CommonConstruct {
213
215
 
214
216
  protected createSiteOriginRequestPolicy() {
215
217
  if (!this.props.siteOriginRequestPolicy) return
218
+ if (!this.props.siteOriginRequestPolicy.originRequestPolicyName)
219
+ throw `SiteOriginRequestPolicy originRequestPolicyName undefined for ${this.id}`
220
+
216
221
  this.siteOriginRequestPolicy = new OriginRequestPolicy(this, `${this.id}-sorp`, {
217
222
  comment: `Request Policy for ${this.id}-distribution - ${this.props.stage} stage`,
218
223
  cookieBehavior: this.props.siteOriginRequestPolicy.cookieBehavior,
219
224
  headerBehavior: this.props.siteOriginRequestPolicy.headerBehavior,
220
- originRequestPolicyName: `${this.id}-origin-request`,
225
+ originRequestPolicyName: this.resourceNameFormatter(this.props.siteOriginRequestPolicy.originRequestPolicyName),
221
226
  queryStringBehavior: this.props.siteOriginRequestPolicy.queryStringBehavior,
222
227
  })
223
228
 
@@ -228,10 +233,13 @@ export class SiteWithLambdaBackend extends CommonConstruct {
228
233
 
229
234
  protected createResponseHeaderPolicy(props: SiteWithLambdaBackendResponseHeadersPolicyProps) {
230
235
  if (!props) return undefined
236
+ if (!props.responseHeadersPolicyName)
237
+ throw `SiteResponseHeadersPolicy responseHeadersPolicyName undefined for ${this.id}`
238
+
231
239
  return new ResponseHeadersPolicy(this, `${this.id}-${props.type}-srhp`, {
232
240
  ...props,
233
241
  comment: `Response Header Policy for ${props.type} for ${this.id}-distribution - ${this.props.stage} stage`,
234
- responseHeadersPolicyName: `${this.id}-${props.type}-response`,
242
+ responseHeadersPolicyName: this.resourceNameFormatter(props.responseHeadersPolicyName),
235
243
  securityHeadersBehavior: {
236
244
  ...props.securityHeadersBehavior,
237
245
  strictTransportSecurity: {
@@ -46,6 +46,8 @@ export class ApiManager {
46
46
  */
47
47
  public createLambdaRestApi(id: string, scope: CommonConstruct, props: LambdaRestApiProps, lambdaFunction: IFunction) {
48
48
  if (!props) throw `Api props undefined for ${id}`
49
+ if (!props.restApiName) throw `Api restApiName undefined for ${id}`
50
+
49
51
  const api = new LambdaRestApi(scope, `${id}`, {
50
52
  ...props,
51
53
  cloudWatchRole: props.cloudWatchRole || false,
@@ -63,7 +65,7 @@ export class ApiManager {
63
65
  handler: lambdaFunction,
64
66
  minCompressionSize: props.minCompressionSizeInBytes ? Size.bytes(props.minCompressionSizeInBytes) : undefined,
65
67
  proxy: props.proxy ?? true,
66
- restApiName: `${props.restApiName}-${scope.props.stage}`,
68
+ restApiName: scope.resourceNameFormatter(props.restApiName, props.resourceNameOptions),
67
69
  })
68
70
 
69
71
  if (props.tags && !_.isEmpty(props.tags)) {
@@ -1,4 +1,5 @@
1
- import { LambdaRestApiProps as LambdaRestApigProps } from 'aws-cdk-lib/aws-apigateway'
1
+ import { LambdaRestApiProps as LambdaRestApigProps, RestApiProps } from 'aws-cdk-lib/aws-apigateway'
2
+ import { ResourceNameFormatterProps } from '../../common'
2
3
  import { TagProps } from '../../types'
3
4
 
4
5
  /**
@@ -6,4 +7,9 @@ import { TagProps } from '../../types'
6
7
  export interface LambdaRestApiProps extends LambdaRestApigProps {
7
8
  tags?: TagProps[]
8
9
  minCompressionSizeInBytes?: number
10
+ resourceNameOptions?: ResourceNameFormatterProps
11
+ }
12
+
13
+ export interface RestApigProps extends RestApiProps {
14
+ resourceNameOptions?: ResourceNameFormatterProps
9
15
  }
@@ -51,7 +51,7 @@ export class AppConfigManager {
51
51
 
52
52
  const application = new CfnApplication(scope, `${id}`, {
53
53
  ...props.application,
54
- name: `${props.application.name}-${scope.props.stage}`,
54
+ name: scope.resourceNameFormatter(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: `${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))
@@ -5,6 +5,7 @@ import {
5
5
  CfnDeploymentStrategyProps,
6
6
  CfnEnvironmentProps,
7
7
  } from 'aws-cdk-lib/aws-appconfig'
8
+ import { ResourceNameFormatterProps } from '../../common'
8
9
 
9
10
  /**
10
11
  */
@@ -15,4 +16,5 @@ export interface AppConfigProps {
15
16
  deploymentStrategy: CfnDeploymentStrategyProps
16
17
  environment: CfnEnvironmentProps
17
18
  id: string
19
+ resourceNameOptions?: ResourceNameFormatterProps
18
20
  }
@@ -275,6 +275,7 @@ export class CloudFrontManager {
275
275
  mountPath?: string
276
276
  ) {
277
277
  if (!props) throw `EdgeFunction props undefined for ${id}`
278
+ if (!props.functionName) throw `EdgeFunction functionName undefined for ${id}`
278
279
 
279
280
  const edgeFunction = new cf.experimental.EdgeFunction(scope, `${id}`, {
280
281
  code: code,
@@ -283,7 +284,7 @@ export class CloudFrontManager {
283
284
  ...environment,
284
285
  },
285
286
  filesystem: accessPoint ? FileSystem.fromEfsAccessPoint(accessPoint, mountPath ?? '/mnt/msg') : undefined,
286
- functionName: `${props.functionName}-${scope.props.stage}`,
287
+ functionName: scope.resourceNameFormatter(props.functionName, props.resourceNameOptions),
287
288
  handler: props.handler ?? 'index.handler',
288
289
  layers: layers,
289
290
  logRetention: props.logRetention,
@@ -351,12 +352,15 @@ export class CloudFrontManager {
351
352
  * @param props
352
353
  */
353
354
  public createCloudfrontFunction(id: string, scope: CommonConstruct, props: CloudfrontFunctionProps) {
355
+ if (!props) throw `CloudFront Function props undefined for ${id}`
356
+ if (!props.functionName) throw `CloudFront Function functionName undefined for ${id}`
357
+
354
358
  const cloudfrontFunction = new Function(scope, `${id}`, {
355
359
  code: FunctionCode.fromFile({
356
360
  filePath: props.functionFilePath,
357
361
  }),
358
362
  comment: props.comment,
359
- functionName: `${props.functionName}-${scope.props.stage}`,
363
+ functionName: scope.resourceNameFormatter(props.functionName, props.resourceNameOptions),
360
364
  })
361
365
 
362
366
  createCfnOutput(`${id}-functionArn`, scope, cloudfrontFunction.functionArn)
@@ -3,6 +3,7 @@ import {
3
3
  CloudFrontWebDistributionProps,
4
4
  FunctionProps,
5
5
  } from 'aws-cdk-lib/aws-cloudfront'
6
+ import { ResourceNameFormatterProps } from '../../common'
6
7
  import { TagProps } from '../../types'
7
8
 
8
9
  /**
@@ -22,4 +23,5 @@ export interface DistributionProps extends CfDistributionProps {
22
23
  export interface CloudfrontFunctionProps extends FunctionProps {
23
24
  eventType: string
24
25
  functionFilePath: string
26
+ resourceNameOptions?: ResourceNameFormatterProps
25
27
  }
@@ -49,6 +49,7 @@ export class CloudTrailManager {
49
49
  logBucketPolicy: CfnBucketPolicy
50
50
  ) {
51
51
  if (!props) throw `CloudTrail props undefined for ${id}`
52
+ if (!props.trailName) throw `CloudTrail trailName undefined for ${id}`
52
53
 
53
54
  const role = scope.iamManager.createRoleForCloudTrail(`${id}Role`, scope, logGroup)
54
55
 
@@ -71,7 +72,7 @@ export class CloudTrailManager {
71
72
  s3BucketName: logBucket.bucketName,
72
73
  s3KeyPrefix: `logs-${props.trailName}`,
73
74
  tags: [{ key: 'service', value: scope.props.name }],
74
- trailName: `${props.trailName}-${scope.props.stage}`,
75
+ trailName: scope.resourceNameFormatter(props.trailName, props.resourceNameOptions),
75
76
  })
76
77
 
77
78
  cloudTrail.addDependency(logBucketPolicy)
@@ -1,5 +1,8 @@
1
1
  import { CfnTrailProps } from 'aws-cdk-lib/aws-cloudtrail'
2
+ import { ResourceNameFormatterProps } from '../../common'
2
3
 
3
4
  /**
4
5
  */
5
- export interface CloudTrailProps extends CfnTrailProps {}
6
+ export interface CloudTrailProps extends CfnTrailProps {
7
+ resourceNameOptions?: ResourceNameFormatterProps
8
+ }
@@ -56,10 +56,11 @@ export class DynamodbManager {
56
56
  */
57
57
  public createTableV2(id: string, scope: CommonConstruct, props: TablePropsV2) {
58
58
  if (!props) throw `Table props undefined for ${id}`
59
+ if (!props.tableName) throw `Table tableName undefined for ${id}`
59
60
 
60
61
  const table = new TableV2(scope, `${id}`, {
61
62
  ...props,
62
- tableName: `${props.tableName}-${scope.props.stage}`,
63
+ tableName: scope.resourceNameFormatter(props.tableName, props.resourceNameOptions),
63
64
  })
64
65
 
65
66
  createCfnOutput(`${id}-tableName`, scope, table.tableName)
@@ -1,4 +1,5 @@
1
1
  import * as dynamodb from 'aws-cdk-lib/aws-dynamodb'
2
+ import { ResourceNameFormatterProps } from '../../common'
2
3
  import { TagProps } from '../../types'
3
4
 
4
5
  /**
@@ -7,4 +8,6 @@ export interface TableProps extends dynamodb.TableProps {
7
8
  tags?: TagProps[]
8
9
  }
9
10
 
10
- export interface TablePropsV2 extends dynamodb.TablePropsV2 {}
11
+ export interface TablePropsV2 extends dynamodb.TablePropsV2 {
12
+ resourceNameOptions?: ResourceNameFormatterProps
13
+ }
@@ -148,6 +148,8 @@ export class EcsManager {
148
148
  logGroup: ILogGroup
149
149
  ) {
150
150
  if (!props) throw `Ecs Load balanced Fargate Service props undefined for ${id}`
151
+ if (!props.loadBalancerName) throw `Ecs loadBalancerName undefined for ${id}`
152
+ if (!props.serviceName) throw `Ecs serviceName undefined for ${id}`
151
153
  if (!props.taskImageOptions)
152
154
  throw `TaskImageOptions for Ecs Load balanced Fargate Service props undefined for ${id}`
153
155
 
@@ -157,12 +159,12 @@ export class EcsManager {
157
159
  cluster,
158
160
  enableECSManagedTags: true,
159
161
  healthCheckGracePeriod: props.healthCheckGracePeriod ?? Duration.seconds(60),
160
- loadBalancerName: `${id}-${scope.props.stage}`,
162
+ loadBalancerName: scope.resourceNameFormatter(props.loadBalancerName, props.resourceNameOptions),
161
163
  runtimePlatform: {
162
164
  cpuArchitecture: props.runtimePlatform?.cpuArchitecture ?? CpuArchitecture.X86_64,
163
165
  operatingSystemFamily: props.runtimePlatform?.operatingSystemFamily ?? OperatingSystemFamily.LINUX,
164
166
  },
165
- serviceName: `${id}-${scope.props.stage}`,
167
+ serviceName: scope.resourceNameFormatter(props.serviceName, props.resourceNameOptions),
166
168
  taskImageOptions: {
167
169
  ...props.taskImageOptions,
168
170
  enableLogging: props.taskImageOptions?.enableLogging ?? true,
@@ -8,6 +8,7 @@ import {
8
8
  } from 'aws-cdk-lib/aws-ecs'
9
9
  import { ApplicationLoadBalancedFargateServiceProps } from 'aws-cdk-lib/aws-ecs-patterns'
10
10
  import { HealthCheck as ElbHealthCheck } from 'aws-cdk-lib/aws-elasticloadbalancingv2'
11
+ import { ResourceNameFormatterProps } from '../../common'
11
12
  import { TagProps } from '../../types'
12
13
 
13
14
  /**
@@ -54,4 +55,5 @@ export interface EcsApplicationLoadBalancedFargateServiceProps extends Applicati
54
55
  logging?: AwsLogDriverProps
55
56
  mountPoints?: MountPoint[]
56
57
  siteScaling?: EcsScalingProps
58
+ resourceNameOptions?: ResourceNameFormatterProps
57
59
  }
@@ -54,11 +54,12 @@ export class EfsManager {
54
54
  vpcSubnets?: SubnetSelection
55
55
  ) {
56
56
  if (!props) throw `EFS props undefined for ${id}`
57
+ if (!props.fileSystemName) throw `EFS fileSystemName undefined for ${id}`
57
58
 
58
59
  const fileSystemId = props.provisionNewOnDeployment ? `${id}-${new Date().getMilliseconds()}` : `${id}`
59
60
  const fileSystem = new FileSystem(scope, `${fileSystemId}`, {
60
61
  ...props,
61
- fileSystemName: props.fileSystemName ? `${props.fileSystemName}-${scope.props.stage}` : undefined,
62
+ fileSystemName: scope.resourceNameFormatter(props.fileSystemName, props.resourceNameOptions),
62
63
  lifecyclePolicy: props.lifecyclePolicy ?? LifecyclePolicy.AFTER_7_DAYS,
63
64
  outOfInfrequentAccessPolicy: props.outOfInfrequentAccessPolicy ?? OutOfInfrequentAccessPolicy.AFTER_1_ACCESS,
64
65
  performanceMode: props.performanceMode ?? PerformanceMode.GENERAL_PURPOSE,
@@ -1,5 +1,6 @@
1
- import { AccessPointOptions, FileSystemProps } from 'aws-cdk-lib/aws-efs'
2
1
  import { AuthorizationConfig } from 'aws-cdk-lib/aws-ecs'
2
+ import { AccessPointOptions, FileSystemProps } from 'aws-cdk-lib/aws-efs'
3
+ import { ResourceNameFormatterProps } from '../../common'
3
4
 
4
5
  /**
5
6
  */
@@ -9,6 +10,7 @@ export interface EfsFileSystemProps extends FileSystemProps {
9
10
  rootDirectory?: string
10
11
  transitEncryption?: string
11
12
  transitEncryptionPort?: number
13
+ resourceNameOptions?: ResourceNameFormatterProps
12
14
  }
13
15
 
14
16
  /**
@@ -38,6 +38,7 @@ export class EksManager {
38
38
  vpc: IVpc
39
39
  ) {
40
40
  if (!props) throw `EksCluster props undefined for ${id}`
41
+ if (!props.clusterName) throw `EksCluster clusterName undefined for ${id}`
41
42
 
42
43
  const appLabel = { app: `${id}`.toLowerCase() }
43
44
 
@@ -81,7 +82,7 @@ export class EksManager {
81
82
  }
82
83
 
83
84
  const cluster = new Cluster(scope, `${id}Cluster`, {
84
- clusterName: `${id.toLowerCase()}-${scope.props.stage}`,
85
+ clusterName: scope.resourceNameFormatter(props.clusterName, props.resourceNameOptions),
85
86
  defaultCapacity: props.appCapacity,
86
87
  defaultCapacityInstance: InstanceType.of(InstanceClass.T3, InstanceSize.LARGE),
87
88
  version: KubernetesVersion.V1_27,
@@ -1,8 +1,10 @@
1
1
  import { ClusterProps } from 'aws-cdk-lib/aws-eks'
2
+ import { ResourceNameFormatterProps } from '../../common'
2
3
 
3
4
  /**
4
5
  */
5
6
  export interface EksClusterProps extends ClusterProps {
6
7
  appCapacity: number
7
8
  appContainerPort: number
9
+ resourceNameOptions?: ResourceNameFormatterProps
8
10
  }
@@ -54,13 +54,14 @@ export class ElastiCacheManager {
54
54
  logDeliveryConfigurations?: any
55
55
  ) {
56
56
  if (!props) throw `ElastiCache props undefined for ${id}`
57
+ if (!props.clusterName) throw `ElastiCache clusterName undefined for ${id}`
57
58
 
58
59
  const subnetGroup = this.createElastiCacheSubnetGroup(`${id}-subnetGroup`, scope, subnetIds)
59
60
 
60
61
  const elasticacheCluster = new CfnCacheCluster(scope, `${id}`, {
61
62
  ...props,
62
63
  cacheSubnetGroupName: subnetGroup.cacheSubnetGroupName,
63
- clusterName: `${id}-${scope.props.stage}`,
64
+ clusterName: scope.resourceNameFormatter(props.clusterName, props.resourceNameOptions),
64
65
  logDeliveryConfigurations,
65
66
  vpcSecurityGroupIds: securityGroupIds,
66
67
  })
@@ -1,8 +1,11 @@
1
1
  import { CfnCacheClusterProps, CfnReplicationGroupProps } from 'aws-cdk-lib/aws-elasticache'
2
+ import { ResourceNameFormatterProps } from '../../common'
2
3
 
3
4
  /**
4
5
  */
5
- export interface ElastiCacheProps extends CfnCacheClusterProps {}
6
+ export interface ElastiCacheProps extends CfnCacheClusterProps {
7
+ resourceNameOptions?: ResourceNameFormatterProps
8
+ }
6
9
 
7
10
  /**
8
11
  */
@@ -43,10 +43,15 @@ export class EventManager {
43
43
  */
44
44
  public createEventBus(id: string, scope: CommonConstruct, props: EventBusProps) {
45
45
  if (!props) throw `EventBus props undefined for ${id}`
46
+ if (!props.eventBusName) throw `EventBus eventBusName undefined for ${id}`
46
47
 
48
+ let eventBusName = props.eventBusName
49
+ if (eventBusName && eventBusName != 'default') {
50
+ eventBusName = scope.resourceNameFormatter(props.eventBusName, props.resourceNameOptions)
51
+ }
47
52
  const eventBus = new EventBus(scope, `${id}`, {
48
53
  ...props,
49
- eventBusName: `${props.eventBusName}-${scope.props.stage}`,
54
+ eventBusName,
50
55
  })
51
56
 
52
57
  createCfnOutput(`${id}-eventBusName`, scope, `${props.eventBusName}-${scope.props.stage}`)
@@ -71,11 +76,12 @@ export class EventManager {
71
76
  targets?: IRuleTarget[]
72
77
  ) {
73
78
  if (!props) throw `EventRule props undefined for ${id}`
79
+ if (!props.ruleName) throw `EventRule ruleName undefined for ${id}`
74
80
 
75
81
  const rule = new Rule(scope, `${id}`, {
76
82
  ...props,
77
83
  eventBus,
78
- ruleName: `${props.ruleName}-${scope.props.stage}`,
84
+ ruleName: scope.resourceNameFormatter(props.ruleName, props.resourceNameOptions),
79
85
  })
80
86
 
81
87
  if (targets && !_.isEmpty(targets)) {
@@ -116,23 +122,30 @@ export class EventManager {
116
122
  scheduleExpression?: string
117
123
  ) {
118
124
  if (!props) throw `EventRule props undefined for ${id}`
125
+ if (!props.name) throw `EventRule name undefined for ${id}`
119
126
 
120
127
  const eventRule = new CfnRule(scope, `${id}`, {
121
128
  ...props,
122
129
  description: 'Rule to send notification to lambda function target',
123
130
  eventBusName,
124
131
  eventPattern,
125
- name: `${props.name}-${scope.props.stage}`,
132
+ name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
126
133
  scheduleExpression,
127
134
  targets: [
128
135
  {
129
136
  arn: lambdaFunction.functionArn,
130
- id: `${id}-${scope.props.stage}`,
137
+ id: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
131
138
  input: props.input ?? undefined,
132
139
  },
133
140
  ],
134
141
  })
135
142
 
143
+ if (props.tags && !_.isEmpty(props.tags)) {
144
+ _.forEach(props.tags, tag => {
145
+ Tags.of(eventRule).add(tag.key, tag.value)
146
+ })
147
+ }
148
+
136
149
  new CfnPermission(scope, `${id}LambdaPermission`, {
137
150
  action: 'lambda:InvokeFunction',
138
151
  functionName: lambdaFunction.functionName,
@@ -168,12 +181,13 @@ export class EventManager {
168
181
  eventPattern?: any
169
182
  ) {
170
183
  if (!props) throw `EventRule props undefined for ${id}`
184
+ if (!props.name) throw `EventRule name undefined for ${id}`
171
185
 
172
186
  const eventRule = new CfnRule(scope, `${id}`, {
173
187
  ...props,
174
188
  description: 'Rule to send notification on new objects in data bucket to ecs task target',
175
189
  eventPattern,
176
- name: `${props.name}-${scope.props.stage}`,
190
+ name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
177
191
  targets: [
178
192
  {
179
193
  arn: cluster.clusterArn,
@@ -185,7 +199,7 @@ export class EventManager {
185
199
  taskCount: 1,
186
200
  taskDefinitionArn: task.taskDefinitionArn,
187
201
  },
188
- id: `${id}-${scope.props.stage}`,
202
+ id: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
189
203
  roleArn: role instanceof Role ? role.roleArn : role.attrArn,
190
204
  },
191
205
  ],
@@ -212,6 +226,9 @@ export class EventManager {
212
226
  sourceQueue: IQueue,
213
227
  targetStepFunction: IStateMachine
214
228
  ) {
229
+ if (!props) throw `Pipe props undefined for ${id}`
230
+ if (!props.name) throw `Pipe name undefined for ${id}`
231
+
215
232
  const pipeRole = scope.iamManager.createRoleForSqsToSfnPipe(
216
233
  `${id}-role`,
217
234
  scope,
@@ -221,7 +238,7 @@ export class EventManager {
221
238
 
222
239
  const pipe = new CfnPipe(scope, `${id}`, {
223
240
  ...props,
224
- name: `${props.name}-${scope.props.stage}`,
241
+ name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
225
242
  roleArn: pipeRole.roleArn,
226
243
  source: sourceQueue.queueArn,
227
244
  sourceParameters: {
@@ -269,6 +286,9 @@ export class EventManager {
269
286
  sourceQueue: IQueue,
270
287
  targetLambdaFunction: IFunction
271
288
  ) {
289
+ if (!props) throw `Pipe props undefined for ${id}`
290
+ if (!props.name) throw `Pipe name undefined for ${id}`
291
+
272
292
  const pipeRole = scope.iamManager.createRoleForSqsToLambdaPipe(
273
293
  `${id}-role`,
274
294
  scope,
@@ -278,7 +298,7 @@ export class EventManager {
278
298
 
279
299
  const pipe = new CfnPipe(scope, `${id}`, {
280
300
  ...props,
281
- name: `${props.name}-${scope.props.stage}`,
301
+ name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
282
302
  roleArn: pipeRole.roleArn,
283
303
  source: sourceQueue.queueArn,
284
304
  sourceParameters: {
@@ -323,6 +343,9 @@ export class EventManager {
323
343
  sourceDynamoDbStreamArn: string,
324
344
  targetLambdaFunction: IFunction
325
345
  ) {
346
+ if (!props) throw `Pipe props undefined for ${id}`
347
+ if (!props.name) throw `Pipe name undefined for ${id}`
348
+
326
349
  const pipeRole = scope.iamManager.createRoleForDynamoDbToLambdaPipe(
327
350
  `${id}-role`,
328
351
  scope,
@@ -332,7 +355,7 @@ export class EventManager {
332
355
 
333
356
  const pipe = new CfnPipe(scope, `${id}`, {
334
357
  ...props,
335
- name: `${props.name}-${scope.props.stage}`,
358
+ name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
336
359
  roleArn: pipeRole.roleArn,
337
360
  source: sourceDynamoDbStreamArn,
338
361
  sourceParameters: {
@@ -1,5 +1,6 @@
1
- import { CfnPipeProps } from 'aws-cdk-lib/aws-pipes'
2
1
  import { CfnRuleProps, EventBusProps as EBProps, RuleProps as EBRuleProps } from 'aws-cdk-lib/aws-events'
2
+ import { CfnPipeProps } from 'aws-cdk-lib/aws-pipes'
3
+ import { ResourceNameFormatterProps } from '../../common'
3
4
  import { TagProps } from '../../types'
4
5
 
5
6
  /**
@@ -10,6 +11,7 @@ export interface SqsToSfnPipeProps extends CfnPipeProps {
10
11
  sfnInvocationType?: string
11
12
  sqsBatchSize?: number
12
13
  sqsMaximumBatchingWindowInSeconds?: number
14
+ resourceNameOptions?: ResourceNameFormatterProps
13
15
  }
14
16
 
15
17
  /**
@@ -19,11 +21,13 @@ export interface SqsToLambdaPipeProps extends CfnPipeProps {
19
21
  sqsBatchSize?: number
20
22
  lambdaInputTemplate?: string
21
23
  sqsMaximumBatchingWindowInSeconds?: number
24
+ resourceNameOptions?: ResourceNameFormatterProps
22
25
  }
23
26
 
24
27
  /**
25
28
  */
26
29
  export interface EventRuleProps extends EBRuleProps {
30
+ resourceNameOptions?: ResourceNameFormatterProps
27
31
  tags?: TagProps[]
28
32
  }
29
33
 
@@ -31,11 +35,15 @@ export interface EventRuleProps extends EBRuleProps {
31
35
  */
32
36
  export interface RuleProps extends CfnRuleProps {
33
37
  input?: string
38
+ resourceNameOptions?: ResourceNameFormatterProps
39
+ tags?: TagProps[]
34
40
  }
35
41
 
36
42
  /**
37
43
  */
38
- export interface EventBusProps extends EBProps {}
44
+ export interface EventBusProps extends EBProps {
45
+ resourceNameOptions?: ResourceNameFormatterProps
46
+ }
39
47
 
40
48
  /**
41
49
  }
@@ -44,4 +52,5 @@ export interface DynamoDbToLambdaPipeProps extends CfnPipeProps {
44
52
  pipeFilterPattern?: any
45
53
  dynamoDbBatchSize?: number
46
54
  dynamoDbStartingPosition: string
55
+ resourceNameOptions?: ResourceNameFormatterProps
47
56
  }
@@ -33,10 +33,13 @@ export class EvidentlyManager {
33
33
  * @param props the project properties
34
34
  */
35
35
  public createProject(id: string, scope: CommonConstruct, props: EvidentlyProjectProps) {
36
+ if (!props) throw `EvidentlyProject props undefined for ${id}`
37
+ if (!props.name) throw `EvidentlyProject name undefined for ${id}`
38
+
36
39
  const project = new CfnProject(scope, `${id}`, {
37
40
  ...props,
38
41
  description: `${props.description} ${scope.props.stage}`,
39
- name: `${props.name}-${scope.props.stage}`,
42
+ name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
40
43
  })
41
44
  createCfnOutput(`${id}-projectArn`, scope, project.attrArn)
42
45
  createCfnOutput(`${id}-projectName`, scope, project.name)
@@ -50,6 +53,8 @@ export class EvidentlyManager {
50
53
  * @param props the feature properties
51
54
  */
52
55
  public createFeature(id: string, scope: CommonConstruct, props: EvidentlyFeatureProps) {
56
+ if (!props) throw `EvidentlyFeature props undefined for ${id}`
57
+
53
58
  const feature = new CfnFeature(scope, `${id}`, props)
54
59
  createCfnOutput(`${id}-featureArn`, scope, feature.attrArn)
55
60
  createCfnOutput(`${id}-featureName`, scope, feature.name)
@@ -63,10 +68,13 @@ export class EvidentlyManager {
63
68
  * @param props the launch properties
64
69
  */
65
70
  public createLaunch(id: string, scope: CommonConstruct, props: EvidentlyLaunchProps) {
71
+ if (!props) throw `EvidentlyLaunch props undefined for ${id}`
72
+ if (!props.name) throw `EvidentlyLaunch name undefined for ${id}`
73
+
66
74
  const launch = new CfnLaunch(scope, `${id}`, {
67
75
  ...props,
68
76
  description: `${props.description} ${scope.props.stage}`,
69
- name: `${props.name}-${scope.props.stage}`,
77
+ name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
70
78
  })
71
79
  createCfnOutput(`${id}-launchArn`, scope, launch.attrArn)
72
80
  createCfnOutput(`${id}-launchName`, scope, launch.name)
@@ -80,10 +88,13 @@ export class EvidentlyManager {
80
88
  * @param props the experiment properties
81
89
  */
82
90
  public createExperiment(id: string, scope: CommonConstruct, props: EvidentlyExperimentProps) {
91
+ if (!props) throw `EvidentlyExperiment props undefined for ${id}`
92
+ if (!props.name) throw `EvidentlyExperiment name undefined for ${id}`
93
+
83
94
  const experiment = new CfnExperiment(scope, `${id}`, {
84
95
  ...props,
85
96
  description: `${props.description} ${scope.props.stage}`,
86
- name: `${props.name}-${scope.props.stage}`,
97
+ name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
87
98
  })
88
99
  createCfnOutput(`${id}-experimentArn`, scope, experiment.attrArn)
89
100
  createCfnOutput(`${id}-experimentName`, scope, experiment.name)
@@ -97,10 +108,13 @@ export class EvidentlyManager {
97
108
  * @param props the segment properties
98
109
  */
99
110
  public createSegment(id: string, scope: CommonConstruct, props: EvidentlySegmentProps) {
111
+ if (!props) throw `EvidentlySegment props undefined for ${id}`
112
+ if (!props.name) throw `EvidentlySegment name undefined for ${id}`
113
+
100
114
  const segment = new CfnSegment(scope, `${id}`, {
101
115
  ...props,
102
116
  description: `${props.description} ${scope.props.stage}`,
103
- name: `${props.name}-${scope.props.stage}`,
117
+ name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
104
118
  })
105
119
  createCfnOutput(`${id}-segmentArn`, scope, segment.attrArn)
106
120
  createCfnOutput(`${id}-segmentName`, scope, segment.name)
@@ -5,10 +5,13 @@ import {
5
5
  CfnProjectProps,
6
6
  CfnSegmentProps,
7
7
  } from 'aws-cdk-lib/aws-evidently'
8
+ import { ResourceNameFormatterProps } from '../../common'
8
9
 
9
10
  /**
10
11
  */
11
- export interface EvidentlyProjectProps extends CfnProjectProps {}
12
+ export interface EvidentlyProjectProps extends CfnProjectProps {
13
+ resourceNameOptions?: ResourceNameFormatterProps
14
+ }
12
15
 
13
16
  /**
14
17
  */
@@ -16,12 +19,18 @@ export interface EvidentlyFeatureProps extends CfnFeatureProps {}
16
19
 
17
20
  /**
18
21
  */
19
- export interface EvidentlyLaunchProps extends CfnLaunchProps {}
22
+ export interface EvidentlyLaunchProps extends CfnLaunchProps {
23
+ resourceNameOptions?: ResourceNameFormatterProps
24
+ }
20
25
 
21
26
  /**
22
27
  */
23
- export interface EvidentlyExperimentProps extends CfnExperimentProps {}
28
+ export interface EvidentlyExperimentProps extends CfnExperimentProps {
29
+ resourceNameOptions?: ResourceNameFormatterProps
30
+ }
24
31
 
25
32
  /**
26
33
  */
27
- export interface EvidentlySegmentProps extends CfnSegmentProps {}
34
+ export interface EvidentlySegmentProps extends CfnSegmentProps {
35
+ resourceNameOptions?: ResourceNameFormatterProps
36
+ }