@gradientedge/cdk-utils 9.13.0 → 9.14.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 (107) hide show
  1. package/dist/src/lib/aws/common/stack.d.ts +1 -0
  2. package/dist/src/lib/aws/common/stack.js +1 -0
  3. package/dist/src/lib/aws/common/types.d.ts +3 -0
  4. package/dist/src/lib/aws/construct/api-to-any-target/main.js +2 -2
  5. package/dist/src/lib/aws/construct/api-to-eventbridge-target/main.js +3 -3
  6. package/dist/src/lib/aws/construct/api-to-eventbridge-target-with-sns/main.js +4 -4
  7. package/dist/src/lib/aws/construct/api-to-lambda-target/main.js +1 -1
  8. package/dist/src/lib/aws/services/api-gateway/main.js +1 -1
  9. package/dist/src/lib/aws/services/api-gateway/types.d.ts +0 -3
  10. package/dist/src/lib/aws/services/appconfig/main.js +2 -2
  11. package/dist/src/lib/aws/services/appconfig/types.d.ts +0 -2
  12. package/dist/src/lib/aws/services/cloudfront/main.js +2 -2
  13. package/dist/src/lib/aws/services/cloudfront/types.d.ts +0 -2
  14. package/dist/src/lib/aws/services/cloudtrail/main.js +1 -1
  15. package/dist/src/lib/aws/services/cloudtrail/types.d.ts +0 -2
  16. package/dist/src/lib/aws/services/cloudwatch/logs.js +6 -2
  17. package/dist/src/lib/aws/services/cloudwatch/main.js +3 -0
  18. package/dist/src/lib/aws/services/codebuild/main.js +1 -1
  19. package/dist/src/lib/aws/services/dynamodb/main.js +2 -2
  20. package/dist/src/lib/aws/services/dynamodb/types.d.ts +0 -3
  21. package/dist/src/lib/aws/services/elastic-container-service/main.js +2 -2
  22. package/dist/src/lib/aws/services/elastic-container-service/types.d.ts +0 -2
  23. package/dist/src/lib/aws/services/elastic-file-system/main.js +1 -1
  24. package/dist/src/lib/aws/services/elastic-file-system/types.d.ts +0 -2
  25. package/dist/src/lib/aws/services/elastic-kubernetes-service/main.js +1 -1
  26. package/dist/src/lib/aws/services/elastic-kubernetes-service/types.d.ts +0 -2
  27. package/dist/src/lib/aws/services/elasticache/main.js +1 -1
  28. package/dist/src/lib/aws/services/elasticache/types.d.ts +0 -2
  29. package/dist/src/lib/aws/services/eventbridge/main.js +9 -9
  30. package/dist/src/lib/aws/services/eventbridge/types.d.ts +0 -7
  31. package/dist/src/lib/aws/services/evidently/main.js +4 -4
  32. package/dist/src/lib/aws/services/evidently/types.d.ts +0 -5
  33. package/dist/src/lib/aws/services/identity-access-management/main.d.ts +20 -20
  34. package/dist/src/lib/aws/services/identity-access-management/main.js +71 -70
  35. package/dist/src/lib/aws/services/key-management-service/main.js +1 -1
  36. package/dist/src/lib/aws/services/key-management-service/types.d.ts +0 -2
  37. package/dist/src/lib/aws/services/lambda/main.js +7 -8
  38. package/dist/src/lib/aws/services/lambda/types.d.ts +0 -3
  39. package/dist/src/lib/aws/services/secrets-manager/main.js +1 -1
  40. package/dist/src/lib/aws/services/secrets-manager/types.d.ts +0 -2
  41. package/dist/src/lib/aws/services/simple-notification-service/main.js +4 -4
  42. package/dist/src/lib/aws/services/simple-notification-service/types.d.ts +0 -2
  43. package/dist/src/lib/aws/services/simple-queue-service/main.js +1 -1
  44. package/dist/src/lib/aws/services/simple-queue-service/types.d.ts +0 -2
  45. package/dist/src/lib/aws/services/simple-storage-service/main.js +1 -1
  46. package/dist/src/lib/aws/services/simple-storage-service/types.d.ts +0 -2
  47. package/dist/src/lib/aws/services/step-function/main.js +1 -1
  48. package/dist/src/lib/aws/services/step-function/types.d.ts +0 -2
  49. package/dist/src/lib/aws/services/systems-manager/main.js +1 -1
  50. package/dist/src/lib/aws/services/systems-manager/types.d.ts +0 -2
  51. package/dist/src/lib/aws/services/virtual-private-cloud/main.js +2 -2
  52. package/dist/src/lib/aws/services/virtual-private-cloud/types.d.ts +0 -2
  53. package/dist/src/lib/aws/services/web-application-firewall/main.js +2 -2
  54. package/dist/src/lib/aws/services/web-application-firewall/types.d.ts +0 -3
  55. package/package.json +6 -6
  56. package/src/lib/aws/common/stack.ts +1 -0
  57. package/src/lib/aws/common/types.ts +1 -0
  58. package/src/lib/aws/construct/api-to-any-target/main.ts +2 -2
  59. package/src/lib/aws/construct/api-to-eventbridge-target/main.ts +3 -3
  60. package/src/lib/aws/construct/api-to-eventbridge-target-with-sns/main.ts +4 -4
  61. package/src/lib/aws/construct/api-to-lambda-target/main.ts +1 -1
  62. package/src/lib/aws/services/api-gateway/main.ts +1 -1
  63. package/src/lib/aws/services/api-gateway/types.ts +1 -4
  64. package/src/lib/aws/services/appconfig/main.ts +5 -2
  65. package/src/lib/aws/services/appconfig/types.ts +0 -1
  66. package/src/lib/aws/services/cloudfront/main.ts +2 -2
  67. package/src/lib/aws/services/cloudfront/types.ts +0 -1
  68. package/src/lib/aws/services/cloudtrail/main.ts +1 -1
  69. package/src/lib/aws/services/cloudtrail/types.ts +1 -3
  70. package/src/lib/aws/services/cloudwatch/logs.ts +4 -2
  71. package/src/lib/aws/services/cloudwatch/main.ts +5 -0
  72. package/src/lib/aws/services/codebuild/main.ts +1 -1
  73. package/src/lib/aws/services/dynamodb/main.ts +2 -2
  74. package/src/lib/aws/services/dynamodb/types.ts +0 -2
  75. package/src/lib/aws/services/elastic-container-service/main.ts +5 -2
  76. package/src/lib/aws/services/elastic-container-service/types.ts +0 -1
  77. package/src/lib/aws/services/elastic-file-system/main.ts +1 -1
  78. package/src/lib/aws/services/elastic-file-system/types.ts +0 -1
  79. package/src/lib/aws/services/elastic-kubernetes-service/main.ts +1 -1
  80. package/src/lib/aws/services/elastic-kubernetes-service/types.ts +0 -1
  81. package/src/lib/aws/services/elasticache/main.ts +1 -1
  82. package/src/lib/aws/services/elasticache/types.ts +1 -3
  83. package/src/lib/aws/services/eventbridge/main.ts +12 -9
  84. package/src/lib/aws/services/eventbridge/types.ts +1 -8
  85. package/src/lib/aws/services/evidently/main.ts +4 -4
  86. package/src/lib/aws/services/evidently/types.ts +4 -12
  87. package/src/lib/aws/services/identity-access-management/main.ts +80 -79
  88. package/src/lib/aws/services/key-management-service/main.ts +1 -1
  89. package/src/lib/aws/services/key-management-service/types.ts +1 -3
  90. package/src/lib/aws/services/lambda/main.ts +13 -7
  91. package/src/lib/aws/services/lambda/types.ts +0 -2
  92. package/src/lib/aws/services/secrets-manager/main.ts +1 -1
  93. package/src/lib/aws/services/secrets-manager/types.ts +1 -3
  94. package/src/lib/aws/services/simple-notification-service/main.ts +4 -4
  95. package/src/lib/aws/services/simple-notification-service/types.ts +1 -3
  96. package/src/lib/aws/services/simple-queue-service/main.ts +1 -1
  97. package/src/lib/aws/services/simple-queue-service/types.ts +0 -1
  98. package/src/lib/aws/services/simple-storage-service/main.ts +1 -1
  99. package/src/lib/aws/services/simple-storage-service/types.ts +0 -1
  100. package/src/lib/aws/services/step-function/main.ts +4 -1
  101. package/src/lib/aws/services/step-function/types.ts +1 -3
  102. package/src/lib/aws/services/systems-manager/main.ts +1 -1
  103. package/src/lib/aws/services/systems-manager/types.ts +1 -3
  104. package/src/lib/aws/services/virtual-private-cloud/main.ts +2 -2
  105. package/src/lib/aws/services/virtual-private-cloud/types.ts +0 -1
  106. package/src/lib/aws/services/web-application-firewall/main.ts +2 -2
  107. package/src/lib/aws/services/web-application-firewall/types.ts +2 -6
@@ -115,17 +115,6 @@ export declare class IamManager {
115
115
  * @param resourceArns list of ARNs to allow access to
116
116
  */
117
117
  statementForWriteEfs(resourceArns?: string[]): PolicyStatement;
118
- /**
119
- * @summary Method to create iam policy to invalidate cloudfront cache
120
- * @param resourceArns list of ARNs to allow access to
121
- */
122
- policyForCloudfrontInvalidation(resourceArns?: string[]): PolicyDocument;
123
- /**
124
- * @summary Method to create iam role to invalidate cloudfront cache
125
- * @param id scoped id of the resource
126
- * @param scope scope in which this resource is defined
127
- */
128
- roleForCloudfrontInvalidation(id: string, scope: CommonConstruct): Role;
129
118
  /**
130
119
  * @summary Method to create iam statement to assume iam role
131
120
  * @param scope scope in which this resource is defined
@@ -181,6 +170,26 @@ export declare class IamManager {
181
170
  * @param resourceArns list of ARNs to allow access to
182
171
  */
183
172
  statementFordynamoDbStream(resourceArns?: string[]): PolicyStatement;
173
+ /**
174
+ * @summary Method to create iam policy to invalidate cloudfront cache
175
+ * @param resourceArns list of ARNs to allow access to
176
+ */
177
+ createPolicyForCloudfrontInvalidation(resourceArns?: string[]): PolicyDocument;
178
+ /**
179
+ * @summary Method to create iam policy for sqs
180
+ * @param id scoped id of the resource
181
+ * @param scope scope in which this resource is defined
182
+ * @param sqsQueue
183
+ * @param eventBridgeRule
184
+ * @param servicePrincipals
185
+ */
186
+ createPolicyForSqsEvent(id: string, scope: CommonConstruct, sqsQueue: Queue, eventBridgeRule: IRule, servicePrincipals?: ServicePrincipal[]): PolicyDocument;
187
+ /**
188
+ * @summary Method to create iam role to invalidate cloudfront cache
189
+ * @param id scoped id of the resource
190
+ * @param scope scope in which this resource is defined
191
+ */
192
+ createRoleForCloudfrontInvalidation(id: string, scope: CommonConstruct): Role;
184
193
  /**
185
194
  * @summary Method to create iam statement for cloud trail
186
195
  * @param id scoped id of the resource
@@ -243,15 +252,6 @@ export declare class IamManager {
243
252
  * @param lambdaArn the arn of the lambda function
244
253
  */
245
254
  createRoleForSqsToLambdaPipe(id: string, scope: CommonConstruct, queueArn: string, lambdaArn: string): Role;
246
- /**
247
- * @summary Method to create iam policy for sqs
248
- * @param id scoped id of the resource
249
- * @param scope scope in which this resource is defined
250
- * @param sqsQueue
251
- * @param eventBridgeRule
252
- * @param servicePrincipals
253
- */
254
- createPolicyForSqsEvent(id: string, scope: CommonConstruct, sqsQueue: Queue, eventBridgeRule: IRule, servicePrincipals?: ServicePrincipal[]): PolicyDocument;
255
255
  /**
256
256
  * @summary Method to create iam statement for dynamoDb to lambda function pipe
257
257
  * @param id scoped id of the resource
@@ -231,42 +231,6 @@ class IamManager {
231
231
  resources: resourceArns ?? ['*'],
232
232
  });
233
233
  }
234
- /**
235
- * @summary Method to create iam policy to invalidate cloudfront cache
236
- * @param resourceArns list of ARNs to allow access to
237
- */
238
- policyForCloudfrontInvalidation(resourceArns) {
239
- return new aws_iam_1.PolicyDocument({
240
- statements: [
241
- this.statementForCreateAnyLogStream(),
242
- this.statementForPutAnyLogEvent(),
243
- this.statementForCloudfrontInvalidation(),
244
- new aws_iam_1.PolicyStatement({
245
- actions: [
246
- 'ecr:GetDownloadUrlForLayer',
247
- 'ecr:BatchGetImage',
248
- 'ecr:BatchCheckLayerAvailability',
249
- 'ecr:GetAuthorizationToken',
250
- ],
251
- effect: aws_iam_1.Effect.ALLOW,
252
- resources: resourceArns ?? ['*'],
253
- }),
254
- ],
255
- });
256
- }
257
- /**
258
- * @summary Method to create iam role to invalidate cloudfront cache
259
- * @param id scoped id of the resource
260
- * @param scope scope in which this resource is defined
261
- */
262
- roleForCloudfrontInvalidation(id, scope) {
263
- return new aws_iam_1.Role(scope, `${id}-install-deps-project-role`, {
264
- assumedBy: new aws_iam_1.ServicePrincipal('codebuild.amazonaws.com'),
265
- inlinePolicies: {
266
- codeBuildPolicy: this.policyForCloudfrontInvalidation(),
267
- },
268
- });
269
- }
270
234
  /**
271
235
  * @summary Method to create iam statement to assume iam role
272
236
  * @param scope scope in which this resource is defined
@@ -399,6 +363,68 @@ class IamManager {
399
363
  resources: resourceArns ?? ['*'],
400
364
  });
401
365
  }
366
+ /**
367
+ * @summary Method to create iam policy to invalidate cloudfront cache
368
+ * @param resourceArns list of ARNs to allow access to
369
+ */
370
+ createPolicyForCloudfrontInvalidation(resourceArns) {
371
+ return new aws_iam_1.PolicyDocument({
372
+ statements: [
373
+ this.statementForCreateAnyLogStream(),
374
+ this.statementForPutAnyLogEvent(),
375
+ this.statementForCloudfrontInvalidation(),
376
+ new aws_iam_1.PolicyStatement({
377
+ actions: [
378
+ 'ecr:GetDownloadUrlForLayer',
379
+ 'ecr:BatchGetImage',
380
+ 'ecr:BatchCheckLayerAvailability',
381
+ 'ecr:GetAuthorizationToken',
382
+ ],
383
+ effect: aws_iam_1.Effect.ALLOW,
384
+ resources: resourceArns ?? ['*'],
385
+ }),
386
+ ],
387
+ });
388
+ }
389
+ /**
390
+ * @summary Method to create iam policy for sqs
391
+ * @param id scoped id of the resource
392
+ * @param scope scope in which this resource is defined
393
+ * @param sqsQueue
394
+ * @param eventBridgeRule
395
+ * @param servicePrincipals
396
+ */
397
+ createPolicyForSqsEvent(id, scope, sqsQueue, eventBridgeRule, servicePrincipals) {
398
+ return new aws_iam_1.PolicyDocument({
399
+ statements: [
400
+ new aws_iam_1.PolicyStatement({
401
+ actions: ['sqs:*'],
402
+ conditions: {
403
+ ArnEquals: {
404
+ 'aws:SourceArn': eventBridgeRule,
405
+ },
406
+ },
407
+ effect: aws_iam_1.Effect.ALLOW,
408
+ principals: servicePrincipals ?? [new aws_iam_1.ServicePrincipal('events.amazonaws.com')],
409
+ resources: [sqsQueue.queueArn],
410
+ }),
411
+ ],
412
+ });
413
+ }
414
+ /**
415
+ * @summary Method to create iam role to invalidate cloudfront cache
416
+ * @param id scoped id of the resource
417
+ * @param scope scope in which this resource is defined
418
+ */
419
+ createRoleForCloudfrontInvalidation(id, scope) {
420
+ return new aws_iam_1.Role(scope, `${id}-install-deps-project-role`, {
421
+ assumedBy: new aws_iam_1.ServicePrincipal('codebuild.amazonaws.com'),
422
+ inlinePolicies: {
423
+ codeBuildPolicy: this.createPolicyForCloudfrontInvalidation(),
424
+ },
425
+ roleName: scope.resourceNameFormatter.format(`${id}-cf-invalidation`, scope.props.resourceNameOptions?.iam),
426
+ });
427
+ }
402
428
  /**
403
429
  * @summary Method to create iam statement for cloud trail
404
430
  * @param id scoped id of the resource
@@ -419,7 +445,7 @@ class IamManager {
419
445
  policyName: scope.resourceNameFormatter.format(`${id}-policy`),
420
446
  },
421
447
  ],
422
- roleName: scope.resourceNameFormatter.format(id),
448
+ roleName: scope.resourceNameFormatter.format(`${id}-trail`, scope.props.resourceNameOptions?.iam),
423
449
  });
424
450
  (0, utils_1.createCfnOutput)(`${id}Arn`, scope, role.attrArn);
425
451
  (0, utils_1.createCfnOutput)(`${id}Name`, scope, role.roleName);
@@ -440,7 +466,7 @@ class IamManager {
440
466
  assumedBy: new aws_iam_1.ServicePrincipal('events.amazonaws.com'),
441
467
  description: `Role for ${id} ECS Task execution from EventBridge`,
442
468
  inlinePolicies: { policy },
443
- roleName: scope.resourceNameFormatter.format(id),
469
+ roleName: scope.resourceNameFormatter.format(`${id}-ecs-event`, scope.props.resourceNameOptions?.iam),
444
470
  });
445
471
  (0, utils_1.createCfnOutput)(`${id}Arn`, scope, role.roleArn);
446
472
  (0, utils_1.createCfnOutput)(`${id}Name`, scope, role.roleName);
@@ -460,7 +486,7 @@ class IamManager {
460
486
  managedPolicies: [
461
487
  aws_iam_1.ManagedPolicy.fromManagedPolicyArn(scope, `${id}-AmazonECSTaskExecutionRolePolicy`, 'arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy'),
462
488
  ],
463
- roleName: scope.resourceNameFormatter.format(id),
489
+ roleName: scope.resourceNameFormatter.format(`${id}-ecs-exec`, scope.props.resourceNameOptions?.iam),
464
490
  });
465
491
  (0, utils_1.createCfnOutput)(`${id}Arn`, scope, role.roleArn);
466
492
  (0, utils_1.createCfnOutput)(`${id}Name`, scope, role.roleName);
@@ -481,7 +507,7 @@ class IamManager {
481
507
  managedPolicies: [
482
508
  aws_iam_1.ManagedPolicy.fromManagedPolicyArn(scope, `${id}-AWSLambdaBasicExecutionRole`, 'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'),
483
509
  ],
484
- roleName: scope.resourceNameFormatter.format(id),
510
+ roleName: scope.resourceNameFormatter.format(`${id}-lambda`, scope.props.resourceNameOptions?.iam),
485
511
  });
486
512
  (0, utils_1.createCfnOutput)(`${id}Arn`, scope, role.roleArn);
487
513
  (0, utils_1.createCfnOutput)(`${id}Name`, scope, role.roleName);
@@ -499,7 +525,7 @@ class IamManager {
499
525
  assumedBy: servicePrincipal ?? new aws_iam_1.ServicePrincipal('appconfig.amazonaws.com'),
500
526
  description: `Role for ${id} AppConfig Secrets`,
501
527
  inlinePolicies: { policy },
502
- roleName: scope.resourceNameFormatter.format(id),
528
+ roleName: scope.resourceNameFormatter.format(`${id}-app-secrets`, scope.props.resourceNameOptions?.iam),
503
529
  });
504
530
  (0, utils_1.createCfnOutput)(`${id}Arn`, scope, role.roleArn);
505
531
  (0, utils_1.createCfnOutput)(`${id}Name`, scope, role.roleName);
@@ -520,7 +546,7 @@ class IamManager {
520
546
  managedPolicies: [
521
547
  aws_iam_1.ManagedPolicy.fromManagedPolicyArn(scope, `${id}-AWSLambdaBasicExecutionRole`, 'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'),
522
548
  ],
523
- roleName: scope.resourceNameFormatter.format(id),
549
+ roleName: scope.resourceNameFormatter.format(`${id}-sfn-exec`, scope.props.resourceNameOptions?.iam),
524
550
  });
525
551
  (0, utils_1.createCfnOutput)(`${id}Arn`, scope, role.roleArn);
526
552
  (0, utils_1.createCfnOutput)(`${id}Name`, scope, role.roleName);
@@ -537,7 +563,7 @@ class IamManager {
537
563
  const role = new aws_iam_1.Role(scope, `${id}`, {
538
564
  assumedBy: new aws_iam_1.ServicePrincipal('pipes.amazonaws.com'),
539
565
  description: `Role for ${id} Pipe`,
540
- roleName: scope.resourceNameFormatter.format(id),
566
+ roleName: scope.resourceNameFormatter.format(`${id}-pipe`, scope.props.resourceNameOptions?.iam),
541
567
  });
542
568
  role.addToPolicy(this.statementForPollQueue([queueArn]));
543
569
  role.addToPolicy(this.statementForStartExecution([stepFunctionArn]));
@@ -556,7 +582,7 @@ class IamManager {
556
582
  const role = new aws_iam_1.Role(scope, `${id}`, {
557
583
  assumedBy: new aws_iam_1.ServicePrincipal('pipes.amazonaws.com'),
558
584
  description: `Role for ${id} Pipe`,
559
- roleName: scope.resourceNameFormatter.format(id),
585
+ roleName: scope.resourceNameFormatter.format(`${id}-pipe`, scope.props.resourceNameOptions?.iam),
560
586
  });
561
587
  role.addToPolicy(this.statementForPollQueue([queueArn]));
562
588
  role.addToPolicy(this.statementForInvokeLambda([lambdaArn]));
@@ -564,31 +590,6 @@ class IamManager {
564
590
  (0, utils_1.createCfnOutput)(`${id}Name`, scope, role.roleName);
565
591
  return role;
566
592
  }
567
- /**
568
- * @summary Method to create iam policy for sqs
569
- * @param id scoped id of the resource
570
- * @param scope scope in which this resource is defined
571
- * @param sqsQueue
572
- * @param eventBridgeRule
573
- * @param servicePrincipals
574
- */
575
- createPolicyForSqsEvent(id, scope, sqsQueue, eventBridgeRule, servicePrincipals) {
576
- return new aws_iam_1.PolicyDocument({
577
- statements: [
578
- new aws_iam_1.PolicyStatement({
579
- actions: ['sqs:*'],
580
- conditions: {
581
- ArnEquals: {
582
- 'aws:SourceArn': eventBridgeRule,
583
- },
584
- },
585
- effect: aws_iam_1.Effect.ALLOW,
586
- principals: servicePrincipals ?? [new aws_iam_1.ServicePrincipal('events.amazonaws.com')],
587
- resources: [sqsQueue.queueArn],
588
- }),
589
- ],
590
- });
591
- }
592
593
  /**
593
594
  * @summary Method to create iam statement for dynamoDb to lambda function pipe
594
595
  * @param id scoped id of the resource
@@ -600,7 +601,7 @@ class IamManager {
600
601
  const role = new aws_iam_1.Role(scope, `${id}`, {
601
602
  assumedBy: new aws_iam_1.ServicePrincipal('pipes.amazonaws.com'),
602
603
  description: `Role for ${id} Pipe`,
603
- roleName: scope.resourceNameFormatter.format(id),
604
+ roleName: scope.resourceNameFormatter.format(`${id}-pipe`, scope.props.resourceNameOptions?.iam),
604
605
  });
605
606
  role.addToPolicy(this.statementFordynamoDbStream([dynamoDbStreamArn]));
606
607
  role.addToPolicy(this.statementForInvokeLambda([lambdaFunctionArn]));
@@ -33,7 +33,7 @@ class KmsManager {
33
33
  throw `KMS Key alias undefined for ${id}`;
34
34
  const key = new aws_kms_1.Key(scope, `${id}`, {
35
35
  ...props,
36
- alias: scope.resourceNameFormatter.format(props.alias, props.resourceNameOptions),
36
+ alias: scope.resourceNameFormatter.format(props.alias, scope.props.resourceNameOptions?.kms),
37
37
  });
38
38
  (0, utils_1.createCfnOutput)(`${id}-keyId`, scope, key.keyId);
39
39
  (0, utils_1.createCfnOutput)(`${id}-keyArn`, scope, key.keyArn);
@@ -1,7 +1,5 @@
1
1
  import { KeyProps } from 'aws-cdk-lib/aws-kms';
2
- import { ResourceNameFormatterProps } from '../../common';
3
2
  /**
4
3
  */
5
4
  export interface KmsKeyProps extends KeyProps {
6
- resourceNameOptions?: ResourceNameFormatterProps;
7
5
  }
@@ -8,7 +8,6 @@ const aws_cdk_lib_1 = require("aws-cdk-lib");
8
8
  const aws_iam_1 = require("aws-cdk-lib/aws-iam");
9
9
  const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
10
10
  const aws_lambda_event_sources_1 = require("aws-cdk-lib/aws-lambda-event-sources");
11
- const aws_logs_1 = require("aws-cdk-lib/aws-logs");
12
11
  const lodash_1 = __importDefault(require("lodash"));
13
12
  const common_1 = require("../../common");
14
13
  const utils_1 = require("../../utils");
@@ -44,7 +43,7 @@ class LambdaManager {
44
43
  compatibleArchitectures: architectures ?? [aws_lambda_1.Architecture.ARM_64],
45
44
  compatibleRuntimes: [scope.props.nodejsRuntime ?? common_1.CommonStack.NODEJS_RUNTIME],
46
45
  description: `${id}`,
47
- layerVersionName: `${id}-${scope.props.stage}`,
46
+ layerVersionName: scope.resourceNameFormatter.format(id, scope.props.resourceNameOptions?.lambdaLayer),
48
47
  });
49
48
  (0, utils_1.createCfnOutput)(`${id}-lambdaLayerArn`, scope, lambdaLayer.layerVersionArn);
50
49
  return lambdaLayer;
@@ -76,7 +75,7 @@ class LambdaManager {
76
75
  throw `Lambda props undefined for ${id}`;
77
76
  if (!props.functionName)
78
77
  throw `Lambda functionName undefined for ${id}`;
79
- const functionName = scope.resourceNameFormatter.format(props.functionName, props.resourceNameOptions);
78
+ const functionName = scope.resourceNameFormatter.format(props.functionName, scope.props.resourceNameOptions?.lambdaFunction);
80
79
  let deadLetterQueue;
81
80
  if (props.deadLetterQueueEnabled) {
82
81
  const redriveQueue = scope.sqsManager.createRedriveQueueForLambda(`${id}-rdq`, scope, props);
@@ -102,8 +101,8 @@ class LambdaManager {
102
101
  functionName,
103
102
  handler: handler || 'index.lambda_handler',
104
103
  layers,
105
- logGroup: new aws_logs_1.LogGroup(scope, `${id}-log-group`, {
106
- logGroupName: `/aws/lambda/${functionName}`,
104
+ logGroup: scope.logManager.createLogGroup(`${id}-log-group`, scope, {
105
+ logGroupName: props.functionName,
107
106
  removalPolicy: aws_cdk_lib_1.RemovalPolicy.DESTROY,
108
107
  retention: scope.props.logRetention ?? logRetention,
109
108
  }),
@@ -181,7 +180,7 @@ class LambdaManager {
181
180
  throw `Lambda props undefined for ${id}`;
182
181
  if (!props.functionName)
183
182
  throw `Lambda functionName undefined for ${id}`;
184
- const functionName = scope.resourceNameFormatter.format(props.functionName, props.resourceNameOptions);
183
+ const functionName = scope.resourceNameFormatter.format(props.functionName, scope.props.resourceNameOptions?.lambdaFunction);
185
184
  let deadLetterQueue;
186
185
  if (props.deadLetterQueueEnabled) {
187
186
  const redriveQueue = scope.sqsManager.createRedriveQueueForLambda(`${id}-rdq`, scope, props);
@@ -205,8 +204,8 @@ class LambdaManager {
205
204
  },
206
205
  filesystem: accessPoint ? aws_lambda_1.FileSystem.fromEfsAccessPoint(accessPoint, mountPath || '/mnt/msg') : undefined,
207
206
  functionName,
208
- logGroup: new aws_logs_1.LogGroup(scope, `${id}-log-group`, {
209
- logGroupName: `/aws/lambda/${functionName}`,
207
+ logGroup: scope.logManager.createLogGroup(`${id}-log-group`, scope, {
208
+ logGroupName: props.functionName,
210
209
  removalPolicy: aws_cdk_lib_1.RemovalPolicy.DESTROY,
211
210
  retention: scope.props.logRetention ?? logRetention,
212
211
  }),
@@ -1,7 +1,6 @@
1
1
  import { EdgeFunctionProps } from 'aws-cdk-lib/aws-cloudfront/lib/experimental';
2
2
  import { AliasProps, FunctionProps } from 'aws-cdk-lib/aws-lambda';
3
3
  import { SqsEventSourceProps } from 'aws-cdk-lib/aws-lambda-event-sources';
4
- import { ResourceNameFormatterProps } from '../../common';
5
4
  import { TagProps } from '../../types';
6
5
  import { QueueProps } from '../simple-queue-service';
7
6
  /**
@@ -21,7 +20,6 @@ export interface LambdaProps extends FunctionProps {
21
20
  redriveq?: QueueProps;
22
21
  tags?: TagProps[];
23
22
  timeoutInSecs?: number;
24
- resourceNameOptions?: ResourceNameFormatterProps;
25
23
  }
26
24
  /**
27
25
  */
@@ -34,7 +32,6 @@ export interface LambdaAliasProps extends AliasProps {
34
32
  export interface LambdaEdgeProps extends EdgeFunctionProps {
35
33
  tags?: TagProps[];
36
34
  timeoutInSecs?: number;
37
- resourceNameOptions?: ResourceNameFormatterProps;
38
35
  }
39
36
  /**
40
37
  */
@@ -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.format(props.secretName, props.resourceNameOptions),
38
+ secretName: scope.resourceNameFormatter.format(props.secretName, scope.props.resourceNameOptions?.secret),
39
39
  });
40
40
  (0, utils_1.createCfnOutput)(`${id}-secretName`, scope, secret.secretName);
41
41
  (0, utils_1.createCfnOutput)(`${id}-secretArn`, scope, secret.secretArn);
@@ -1,5 +1,3 @@
1
1
  import { SecretProps } from 'aws-cdk-lib/aws-secretsmanager';
2
- import { ResourceNameFormatterProps } from '../../common';
3
2
  export interface SecretBaseProps extends SecretProps {
4
- resourceNameOptions?: ResourceNameFormatterProps;
5
3
  }
@@ -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.format(props.topicName, props.resourceNameOptions),
43
- topicName: scope.resourceNameFormatter.format(props.topicName, props.resourceNameOptions),
42
+ displayName: scope.resourceNameFormatter.format(props.topicName, scope.props.resourceNameOptions?.sns),
43
+ topicName: scope.resourceNameFormatter.format(props.topicName, scope.props.resourceNameOptions?.sns),
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.format(props.topicName, props.resourceNameOptions),
67
- topicName: scope.resourceNameFormatter.format(props.topicName, props.resourceNameOptions),
66
+ displayName: scope.resourceNameFormatter.format(props.topicName, scope.props.resourceNameOptions?.sns),
67
+ topicName: scope.resourceNameFormatter.format(props.topicName, scope.props.resourceNameOptions?.sns),
68
68
  });
69
69
  topic.addSubscription(new aws_sns_subscriptions_1.LambdaSubscription(lambdaFunction));
70
70
  (0, utils_1.createCfnOutput)(`${id}-subscriptionArn`, scope, topic.topicArn);
@@ -1,7 +1,5 @@
1
1
  import { TopicProps } from 'aws-cdk-lib/aws-sns';
2
- import { ResourceNameFormatterProps } from '../../common';
3
2
  /**
4
3
  */
5
4
  export interface SubscriptionProps extends TopicProps {
6
- resourceNameOptions?: ResourceNameFormatterProps;
7
5
  }
@@ -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.format(props.queueName, props.resourceNameOptions);
40
+ let queueName = scope.resourceNameFormatter.format(props.queueName, scope.props.resourceNameOptions?.sqs);
41
41
  if (props.fifo)
42
42
  queueName += '.fifo';
43
43
  const queue = new aws_sqs_1.Queue(scope, id, {
@@ -1,5 +1,4 @@
1
1
  import * as sqs from 'aws-cdk-lib/aws-sqs';
2
- import { ResourceNameFormatterProps } from '../../common';
3
2
  import { TagProps } from '../../types';
4
3
  /**
5
4
  */
@@ -13,5 +12,4 @@ export interface QueueProps extends sqs.QueueProps {
13
12
  retryBatchSize?: number;
14
13
  tags?: TagProps[];
15
14
  visibilityTimeoutInSecs?: number;
16
- resourceNameOptions?: ResourceNameFormatterProps;
17
15
  }
@@ -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.format(bucketName, props.resourceNameOptions);
79
+ return scope.resourceNameFormatter.format(bucketName, scope.props.resourceNameOptions?.s3);
80
80
  }
81
81
  /**
82
82
  * @summary Method to create a s3 bucket
@@ -1,6 +1,5 @@
1
1
  import * as s3 from 'aws-cdk-lib/aws-s3';
2
2
  import * as s3deploy from 'aws-cdk-lib/aws-s3-deployment';
3
- import { ResourceNameFormatterProps } from '../../common';
4
3
  import { TagProps } from '../../types';
5
4
  /**
6
5
  */
@@ -22,6 +21,5 @@ export interface S3BucketProps extends s3.BucketProps {
22
21
  existingBucket?: boolean;
23
22
  lifecycleRules?: LifecycleRule[];
24
23
  logBucketName?: string;
25
- resourceNameOptions?: ResourceNameFormatterProps;
26
24
  tags?: TagProps[];
27
25
  }
@@ -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.format(props.stateMachineName, props.resourceNameOptions),
380
+ stateMachineName: scope.resourceNameFormatter.format(props.stateMachineName, scope.props.resourceNameOptions?.stepFunction),
381
381
  });
382
382
  (0, utils_1.createCfnOutput)(`${id}-stateMachineName`, scope, stateMachine.stateMachineName);
383
383
  (0, utils_1.createCfnOutput)(`${id}-stateMachineArn`, scope, stateMachine.stateMachineArn);
@@ -1,6 +1,5 @@
1
1
  import { ChoiceProps, FailProps, MapProps, ParallelProps, PassProps, RetryProps, StateMachineProps, SucceedProps, WaitProps } from 'aws-cdk-lib/aws-stepfunctions';
2
2
  import { CallApiGatewayRestApiEndpointProps, DynamoDeleteItemProps, DynamoGetItemProps, DynamoPutItemProps, LambdaInvokeProps, SqsSendMessageProps, StepFunctionsStartExecutionProps } from 'aws-cdk-lib/aws-stepfunctions-tasks';
3
- import { ResourceNameFormatterProps } from '../../common';
4
3
  /**
5
4
  */
6
5
  export interface SfnSucceedProps extends SucceedProps {
@@ -77,7 +76,6 @@ export interface SfnCallApiGatewayRestApiEndpointProps extends CallApiGatewayRes
77
76
  /**
78
77
  */
79
78
  export interface SfnStateMachineProps extends StateMachineProps {
80
- resourceNameOptions?: ResourceNameFormatterProps;
81
79
  }
82
80
  /**
83
81
  */
@@ -36,7 +36,7 @@ class SsmManager {
36
36
  const parameter = new aws_ssm_1.StringParameter(scope, `${id}`, {
37
37
  ...props,
38
38
  description: `${props.description} - ${scope.props.stage} stage`,
39
- parameterName: scope.resourceNameFormatter.format(props.parameterName, props.resourceNameOptions),
39
+ parameterName: scope.resourceNameFormatter.format(props.parameterName, scope.props.resourceNameOptions?.ssm),
40
40
  });
41
41
  (0, utils_1.createCfnOutput)(`${id}-parameterArn`, scope, parameter.parameterArn);
42
42
  (0, utils_1.createCfnOutput)(`${id}-parameterName`, scope, parameter.parameterName);
@@ -1,5 +1,4 @@
1
1
  import { StringParameterProps } from 'aws-cdk-lib/aws-ssm';
2
- import { ResourceNameFormatterProps } from '../../common';
3
2
  /**
4
3
  */
5
4
  export interface SSMParameterReaderProps {
@@ -7,5 +6,4 @@ export interface SSMParameterReaderProps {
7
6
  region: string;
8
7
  }
9
8
  export interface SSMStringParameterProps extends StringParameterProps {
10
- resourceNameOptions?: ResourceNameFormatterProps;
11
9
  }
@@ -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.format(props.vpcName, props.resourceNameOptions);
43
+ const vpcName = scope.resourceNameFormatter.format(props.vpcName, scope.props.resourceNameOptions?.vpc);
44
44
  let vpc;
45
45
  if (props.isIPV6) {
46
46
  vpc = new ipv6_1.Ipv6Vpc(scope, `${id}`, {
@@ -76,7 +76,7 @@ class VpcManager {
76
76
  */
77
77
  createCommonVpc(id, scope, props, vpcIdentifier) {
78
78
  const vpc = this.createVpc(id, scope, props);
79
- aws_cdk_lib_1.Tags.of(vpc).add('Name', scope.resourceNameFormatter.format(vpcIdentifier ?? CommonVpcIdentifier, props.resourceNameOptions));
79
+ aws_cdk_lib_1.Tags.of(vpc).add('Name', scope.resourceNameFormatter.format(vpcIdentifier ?? CommonVpcIdentifier, scope.props.resourceNameOptions?.vpc));
80
80
  return vpc;
81
81
  }
82
82
  /**
@@ -1,6 +1,4 @@
1
1
  import * as ec2 from 'aws-cdk-lib/aws-ec2';
2
- import { ResourceNameFormatterProps } from '../../common';
3
2
  export interface VpcProps extends ec2.VpcProps {
4
3
  isIPV6?: boolean;
5
- resourceNameOptions?: ResourceNameFormatterProps;
6
4
  }
@@ -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.format(props.name, props.resourceNameOptions),
37
+ name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.waf),
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.format(props.name, props.resourceNameOptions),
57
+ name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.waf),
58
58
  tags: [{ key: 'service', value: scope.props.name }],
59
59
  });
60
60
  (0, utils_1.createCfnOutput)(`${id}-webAclId`, scope, webAcl.attrId);
@@ -1,12 +1,9 @@
1
1
  import { CfnIPSetProps, CfnWebACLProps } from 'aws-cdk-lib/aws-wafv2';
2
- import { ResourceNameFormatterProps } from '../../common';
3
2
  /**
4
3
  */
5
4
  export interface WafIPSetProps extends CfnIPSetProps {
6
- resourceNameOptions?: ResourceNameFormatterProps;
7
5
  }
8
6
  /**
9
7
  */
10
8
  export interface WafWebACLProps extends CfnWebACLProps {
11
- resourceNameOptions?: ResourceNameFormatterProps;
12
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "9.13.0",
3
+ "version": "9.14.0",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -53,16 +53,16 @@
53
53
  "@aws-sdk/client-secrets-manager": "^3.637.0",
54
54
  "@aws-sdk/credential-providers": "^3.637.0",
55
55
  "@aws-sdk/types": "^3.609.0",
56
- "@cdktf/provider-aws": "^19.32.0",
56
+ "@cdktf/provider-aws": "^19.33.0",
57
57
  "@cdktf/provider-azurerm": "^13.0.0",
58
58
  "@cdktf/provider-cloudflare": "^11.18.0",
59
59
  "@types/lodash": "^4.17.7",
60
- "@types/node": "^22.5.0",
60
+ "@types/node": "^22.5.1",
61
61
  "@types/uuid": "^10.0.0",
62
62
  "app-root-path": "^3.1.0",
63
- "aws-cdk-lib": "^2.154.1",
63
+ "aws-cdk-lib": "^2.155.0",
64
64
  "cdktf": "^0.20.8",
65
- "cdktf-local-exec": "^0.5.34",
65
+ "cdktf-local-exec": "^0.5.35",
66
66
  "constructs": "^10.3.0",
67
67
  "lodash": "^4.17.21",
68
68
  "moment": "^2.30.1",
@@ -78,7 +78,7 @@
78
78
  "@types/jest": "^29.5.12",
79
79
  "@typescript-eslint/eslint-plugin": "^8.3.0",
80
80
  "@typescript-eslint/parser": "^8.3.0",
81
- "aws-cdk": "^2.154.1",
81
+ "aws-cdk": "^2.155.0",
82
82
  "better-docs": "^2.7.3",
83
83
  "codecov": "^3.8.3",
84
84
  "commitizen": "^4.3.0",
@@ -60,6 +60,7 @@ export class CommonStack extends Stack {
60
60
  region: this.node.tryGetContext('region'),
61
61
  globalPrefix: this.node.tryGetContext('globalPrefix'),
62
62
  globalSuffix: this.node.tryGetContext('globalSuffix'),
63
+ resourceNameOptions: this.node.tryGetContext('resourceNameOptions'),
63
64
  resourcePrefix: this.node.tryGetContext('resourcePrefix'),
64
65
  resourceSuffix: this.node.tryGetContext('resourceSuffix'),
65
66
  skipStageForARecords: this.node.tryGetContext('skipStageForARecords'),
@@ -18,6 +18,7 @@ export interface CommonStackProps extends BaseProps, StackProps {
18
18
  excludeDomainNameForBuckets?: boolean
19
19
  excludeAccountNumberForBuckets?: boolean
20
20
  nodejsRuntime?: Runtime
21
+ resourceNameOptions?: { [key: string]: ResourceNameFormatterProps }
21
22
  }
22
23
 
23
24
  export interface ResourceNameFormatterProps {