@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
@@ -113,6 +113,10 @@ class EcsManager {
113
113
  createLoadBalancedFargateService(id, scope, props, cluster, logGroup) {
114
114
  if (!props)
115
115
  throw `Ecs Load balanced Fargate Service props undefined for ${id}`;
116
+ if (!props.loadBalancerName)
117
+ throw `Ecs loadBalancerName undefined for ${id}`;
118
+ if (!props.serviceName)
119
+ throw `Ecs serviceName undefined for ${id}`;
116
120
  if (!props.taskImageOptions)
117
121
  throw `TaskImageOptions for Ecs Load balanced Fargate Service props undefined for ${id}`;
118
122
  const fargateService = new aws_ecs_patterns_1.ApplicationLoadBalancedFargateService(scope, `${id}-ecs-service`, {
@@ -121,12 +125,12 @@ class EcsManager {
121
125
  cluster,
122
126
  enableECSManagedTags: true,
123
127
  healthCheckGracePeriod: props.healthCheckGracePeriod ?? aws_cdk_lib_1.Duration.seconds(60),
124
- loadBalancerName: `${id}-${scope.props.stage}`,
128
+ loadBalancerName: scope.resourceNameFormatter(props.loadBalancerName, props.resourceNameOptions),
125
129
  runtimePlatform: {
126
130
  cpuArchitecture: props.runtimePlatform?.cpuArchitecture ?? aws_ecs_1.CpuArchitecture.X86_64,
127
131
  operatingSystemFamily: props.runtimePlatform?.operatingSystemFamily ?? aws_ecs_1.OperatingSystemFamily.LINUX,
128
132
  },
129
- serviceName: `${id}-${scope.props.stage}`,
133
+ serviceName: scope.resourceNameFormatter(props.serviceName, props.resourceNameOptions),
130
134
  taskImageOptions: {
131
135
  ...props.taskImageOptions,
132
136
  enableLogging: props.taskImageOptions?.enableLogging ?? true,
@@ -2,6 +2,7 @@ import { ScalingSchedule } from 'aws-cdk-lib/aws-applicationautoscaling';
2
2
  import { AwsLogDriverProps, ClusterProps, HealthCheck as FargateHealthCheck, MountPoint, TaskDefinitionProps } from 'aws-cdk-lib/aws-ecs';
3
3
  import { ApplicationLoadBalancedFargateServiceProps } from 'aws-cdk-lib/aws-ecs-patterns';
4
4
  import { HealthCheck as ElbHealthCheck } from 'aws-cdk-lib/aws-elasticloadbalancingv2';
5
+ import { ResourceNameFormatterProps } from '../../common';
5
6
  import { TagProps } from '../../types';
6
7
  /**
7
8
  */
@@ -42,4 +43,5 @@ export interface EcsApplicationLoadBalancedFargateServiceProps extends Applicati
42
43
  logging?: AwsLogDriverProps;
43
44
  mountPoints?: MountPoint[];
44
45
  siteScaling?: EcsScalingProps;
46
+ resourceNameOptions?: ResourceNameFormatterProps;
45
47
  }
@@ -47,10 +47,12 @@ class EfsManager {
47
47
  createFileSystem(id, scope, props, vpc, accessPointOptions, securityGroup, vpcSubnets) {
48
48
  if (!props)
49
49
  throw `EFS props undefined for ${id}`;
50
+ if (!props.fileSystemName)
51
+ throw `EFS fileSystemName undefined for ${id}`;
50
52
  const fileSystemId = props.provisionNewOnDeployment ? `${id}-${new Date().getMilliseconds()}` : `${id}`;
51
53
  const fileSystem = new aws_efs_1.FileSystem(scope, `${fileSystemId}`, {
52
54
  ...props,
53
- fileSystemName: props.fileSystemName ? `${props.fileSystemName}-${scope.props.stage}` : undefined,
55
+ fileSystemName: scope.resourceNameFormatter(props.fileSystemName, props.resourceNameOptions),
54
56
  lifecyclePolicy: props.lifecyclePolicy ?? aws_efs_1.LifecyclePolicy.AFTER_7_DAYS,
55
57
  outOfInfrequentAccessPolicy: props.outOfInfrequentAccessPolicy ?? aws_efs_1.OutOfInfrequentAccessPolicy.AFTER_1_ACCESS,
56
58
  performanceMode: props.performanceMode ?? aws_efs_1.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
  export interface EfsFileSystemProps extends FileSystemProps {
@@ -8,6 +9,7 @@ export interface EfsFileSystemProps extends FileSystemProps {
8
9
  rootDirectory?: string;
9
10
  transitEncryption?: string;
10
11
  transitEncryptionPort?: number;
12
+ resourceNameOptions?: ResourceNameFormatterProps;
11
13
  }
12
14
  /**
13
15
  */
@@ -32,6 +32,8 @@ class EksManager {
32
32
  createEksDeployment(id, scope, props, image, vpc) {
33
33
  if (!props)
34
34
  throw `EksCluster props undefined for ${id}`;
35
+ if (!props.clusterName)
36
+ throw `EksCluster clusterName undefined for ${id}`;
35
37
  const appLabel = { app: `${id}`.toLowerCase() };
36
38
  const deployment = {
37
39
  apiVersion: 'apps/v1',
@@ -71,7 +73,7 @@ class EksManager {
71
73
  },
72
74
  };
73
75
  const cluster = new aws_eks_1.Cluster(scope, `${id}Cluster`, {
74
- clusterName: `${id.toLowerCase()}-${scope.props.stage}`,
76
+ clusterName: scope.resourceNameFormatter(props.clusterName, props.resourceNameOptions),
75
77
  defaultCapacity: props.appCapacity,
76
78
  defaultCapacityInstance: aws_ec2_1.InstanceType.of(aws_ec2_1.InstanceClass.T3, aws_ec2_1.InstanceSize.LARGE),
77
79
  version: aws_eks_1.KubernetesVersion.V1_27,
@@ -1,7 +1,9 @@
1
1
  import { ClusterProps } from 'aws-cdk-lib/aws-eks';
2
+ import { ResourceNameFormatterProps } from '../../common';
2
3
  /**
3
4
  */
4
5
  export interface EksClusterProps extends ClusterProps {
5
6
  appCapacity: number;
6
7
  appContainerPort: number;
8
+ resourceNameOptions?: ResourceNameFormatterProps;
7
9
  }
@@ -50,11 +50,13 @@ class ElastiCacheManager {
50
50
  createElastiCache(id, scope, props, subnetIds, securityGroupIds, logDeliveryConfigurations) {
51
51
  if (!props)
52
52
  throw `ElastiCache props undefined for ${id}`;
53
+ if (!props.clusterName)
54
+ throw `ElastiCache clusterName undefined for ${id}`;
53
55
  const subnetGroup = this.createElastiCacheSubnetGroup(`${id}-subnetGroup`, scope, subnetIds);
54
56
  const elasticacheCluster = new aws_elasticache_1.CfnCacheCluster(scope, `${id}`, {
55
57
  ...props,
56
58
  cacheSubnetGroupName: subnetGroup.cacheSubnetGroupName,
57
- clusterName: `${id}-${scope.props.stage}`,
59
+ clusterName: scope.resourceNameFormatter(props.clusterName, props.resourceNameOptions),
58
60
  logDeliveryConfigurations,
59
61
  vpcSecurityGroupIds: securityGroupIds,
60
62
  });
@@ -1,7 +1,9 @@
1
1
  import { CfnCacheClusterProps, CfnReplicationGroupProps } from 'aws-cdk-lib/aws-elasticache';
2
+ import { ResourceNameFormatterProps } from '../../common';
2
3
  /**
3
4
  */
4
5
  export interface ElastiCacheProps extends CfnCacheClusterProps {
6
+ resourceNameOptions?: ResourceNameFormatterProps;
5
7
  }
6
8
  /**
7
9
  */
@@ -37,9 +37,15 @@ class EventManager {
37
37
  createEventBus(id, scope, props) {
38
38
  if (!props)
39
39
  throw `EventBus props undefined for ${id}`;
40
+ if (!props.eventBusName)
41
+ throw `EventBus eventBusName undefined for ${id}`;
42
+ let eventBusName = props.eventBusName;
43
+ if (eventBusName && eventBusName != 'default') {
44
+ eventBusName = scope.resourceNameFormatter(props.eventBusName, props.resourceNameOptions);
45
+ }
40
46
  const eventBus = new aws_events_1.EventBus(scope, `${id}`, {
41
47
  ...props,
42
- eventBusName: `${props.eventBusName}-${scope.props.stage}`,
48
+ eventBusName,
43
49
  });
44
50
  (0, utils_1.createCfnOutput)(`${id}-eventBusName`, scope, `${props.eventBusName}-${scope.props.stage}`);
45
51
  (0, utils_1.createCfnOutput)(`${id}-eventBusArn`, scope, eventBus.eventBusArn);
@@ -56,10 +62,12 @@ class EventManager {
56
62
  createRule(id, scope, props, eventBus, targets) {
57
63
  if (!props)
58
64
  throw `EventRule props undefined for ${id}`;
65
+ if (!props.ruleName)
66
+ throw `EventRule ruleName undefined for ${id}`;
59
67
  const rule = new aws_events_1.Rule(scope, `${id}`, {
60
68
  ...props,
61
69
  eventBus,
62
- ruleName: `${props.ruleName}-${scope.props.stage}`,
70
+ ruleName: scope.resourceNameFormatter(props.ruleName, props.resourceNameOptions),
63
71
  });
64
72
  if (targets && !lodash_1.default.isEmpty(targets)) {
65
73
  lodash_1.default.forEach(targets, target => {
@@ -88,21 +96,28 @@ class EventManager {
88
96
  createLambdaRule(id, scope, props, lambdaFunction, eventBusName, eventPattern, scheduleExpression) {
89
97
  if (!props)
90
98
  throw `EventRule props undefined for ${id}`;
99
+ if (!props.name)
100
+ throw `EventRule name undefined for ${id}`;
91
101
  const eventRule = new aws_events_1.CfnRule(scope, `${id}`, {
92
102
  ...props,
93
103
  description: 'Rule to send notification to lambda function target',
94
104
  eventBusName,
95
105
  eventPattern,
96
- name: `${props.name}-${scope.props.stage}`,
106
+ name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
97
107
  scheduleExpression,
98
108
  targets: [
99
109
  {
100
110
  arn: lambdaFunction.functionArn,
101
- id: `${id}-${scope.props.stage}`,
111
+ id: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
102
112
  input: props.input ?? undefined,
103
113
  },
104
114
  ],
105
115
  });
116
+ if (props.tags && !lodash_1.default.isEmpty(props.tags)) {
117
+ lodash_1.default.forEach(props.tags, tag => {
118
+ aws_cdk_lib_1.Tags.of(eventRule).add(tag.key, tag.value);
119
+ });
120
+ }
106
121
  new aws_lambda_1.CfnPermission(scope, `${id}LambdaPermission`, {
107
122
  action: 'lambda:InvokeFunction',
108
123
  functionName: lambdaFunction.functionName,
@@ -127,11 +142,13 @@ class EventManager {
127
142
  createFargateTaskRule(id, scope, props, cluster, task, subnetIds, role, eventPattern) {
128
143
  if (!props)
129
144
  throw `EventRule props undefined for ${id}`;
145
+ if (!props.name)
146
+ throw `EventRule name undefined for ${id}`;
130
147
  const eventRule = new aws_events_1.CfnRule(scope, `${id}`, {
131
148
  ...props,
132
149
  description: 'Rule to send notification on new objects in data bucket to ecs task target',
133
150
  eventPattern,
134
- name: `${props.name}-${scope.props.stage}`,
151
+ name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
135
152
  targets: [
136
153
  {
137
154
  arn: cluster.clusterArn,
@@ -143,7 +160,7 @@ class EventManager {
143
160
  taskCount: 1,
144
161
  taskDefinitionArn: task.taskDefinitionArn,
145
162
  },
146
- id: `${id}-${scope.props.stage}`,
163
+ id: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
147
164
  roleArn: role instanceof aws_iam_1.Role ? role.roleArn : role.attrArn,
148
165
  },
149
166
  ],
@@ -161,10 +178,14 @@ class EventManager {
161
178
  * @param targetStepFunction the target step function
162
179
  */
163
180
  createSqsToSfnCfnPipe(id, scope, props, sourceQueue, targetStepFunction) {
181
+ if (!props)
182
+ throw `Pipe props undefined for ${id}`;
183
+ if (!props.name)
184
+ throw `Pipe name undefined for ${id}`;
164
185
  const pipeRole = scope.iamManager.createRoleForSqsToSfnPipe(`${id}-role`, scope, sourceQueue.queueArn, targetStepFunction.stateMachineArn);
165
186
  const pipe = new aws_pipes_1.CfnPipe(scope, `${id}`, {
166
187
  ...props,
167
- name: `${props.name}-${scope.props.stage}`,
188
+ name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
168
189
  roleArn: pipeRole.roleArn,
169
190
  source: sourceQueue.queueArn,
170
191
  sourceParameters: {
@@ -203,10 +224,14 @@ class EventManager {
203
224
  * @param targetLambdaFunction the target lambda function
204
225
  */
205
226
  createSqsToLambdaCfnPipe(id, scope, props, sourceQueue, targetLambdaFunction) {
227
+ if (!props)
228
+ throw `Pipe props undefined for ${id}`;
229
+ if (!props.name)
230
+ throw `Pipe name undefined for ${id}`;
206
231
  const pipeRole = scope.iamManager.createRoleForSqsToLambdaPipe(`${id}-role`, scope, sourceQueue.queueArn, targetLambdaFunction.functionArn);
207
232
  const pipe = new aws_pipes_1.CfnPipe(scope, `${id}`, {
208
233
  ...props,
209
- name: `${props.name}-${scope.props.stage}`,
234
+ name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
210
235
  roleArn: pipeRole.roleArn,
211
236
  source: sourceQueue.queueArn,
212
237
  sourceParameters: {
@@ -242,10 +267,14 @@ class EventManager {
242
267
  * @param targetLambdaFunction the target lambda function
243
268
  */
244
269
  createDynamoDbToLambdaCfnPipe(id, scope, props, sourceDynamoDbStreamArn, targetLambdaFunction) {
270
+ if (!props)
271
+ throw `Pipe props undefined for ${id}`;
272
+ if (!props.name)
273
+ throw `Pipe name undefined for ${id}`;
245
274
  const pipeRole = scope.iamManager.createRoleForDynamoDbToLambdaPipe(`${id}-role`, scope, sourceDynamoDbStreamArn, targetLambdaFunction.functionArn);
246
275
  const pipe = new aws_pipes_1.CfnPipe(scope, `${id}`, {
247
276
  ...props,
248
- name: `${props.name}-${scope.props.stage}`,
277
+ name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
249
278
  roleArn: pipeRole.roleArn,
250
279
  source: sourceDynamoDbStreamArn,
251
280
  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
  */
@@ -9,6 +10,7 @@ export interface SqsToSfnPipeProps extends CfnPipeProps {
9
10
  sfnInvocationType?: string;
10
11
  sqsBatchSize?: number;
11
12
  sqsMaximumBatchingWindowInSeconds?: number;
13
+ resourceNameOptions?: ResourceNameFormatterProps;
12
14
  }
13
15
  /**
14
16
  */
@@ -17,20 +19,25 @@ export interface SqsToLambdaPipeProps extends CfnPipeProps {
17
19
  sqsBatchSize?: number;
18
20
  lambdaInputTemplate?: string;
19
21
  sqsMaximumBatchingWindowInSeconds?: number;
22
+ resourceNameOptions?: ResourceNameFormatterProps;
20
23
  }
21
24
  /**
22
25
  */
23
26
  export interface EventRuleProps extends EBRuleProps {
27
+ resourceNameOptions?: ResourceNameFormatterProps;
24
28
  tags?: TagProps[];
25
29
  }
26
30
  /**
27
31
  */
28
32
  export interface RuleProps extends CfnRuleProps {
29
33
  input?: string;
34
+ resourceNameOptions?: ResourceNameFormatterProps;
35
+ tags?: TagProps[];
30
36
  }
31
37
  /**
32
38
  */
33
39
  export interface EventBusProps extends EBProps {
40
+ resourceNameOptions?: ResourceNameFormatterProps;
34
41
  }
35
42
  /**
36
43
  }
@@ -39,4 +46,5 @@ export interface DynamoDbToLambdaPipeProps extends CfnPipeProps {
39
46
  pipeFilterPattern?: any;
40
47
  dynamoDbBatchSize?: number;
41
48
  dynamoDbStartingPosition: string;
49
+ resourceNameOptions?: ResourceNameFormatterProps;
42
50
  }
@@ -27,10 +27,14 @@ class EvidentlyManager {
27
27
  * @param props the project properties
28
28
  */
29
29
  createProject(id, scope, props) {
30
+ if (!props)
31
+ throw `EvidentlyProject props undefined for ${id}`;
32
+ if (!props.name)
33
+ throw `EvidentlyProject name undefined for ${id}`;
30
34
  const project = new aws_evidently_1.CfnProject(scope, `${id}`, {
31
35
  ...props,
32
36
  description: `${props.description} ${scope.props.stage}`,
33
- name: `${props.name}-${scope.props.stage}`,
37
+ name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
34
38
  });
35
39
  (0, utils_1.createCfnOutput)(`${id}-projectArn`, scope, project.attrArn);
36
40
  (0, utils_1.createCfnOutput)(`${id}-projectName`, scope, project.name);
@@ -43,6 +47,8 @@ class EvidentlyManager {
43
47
  * @param props the feature properties
44
48
  */
45
49
  createFeature(id, scope, props) {
50
+ if (!props)
51
+ throw `EvidentlyFeature props undefined for ${id}`;
46
52
  const feature = new aws_evidently_1.CfnFeature(scope, `${id}`, props);
47
53
  (0, utils_1.createCfnOutput)(`${id}-featureArn`, scope, feature.attrArn);
48
54
  (0, utils_1.createCfnOutput)(`${id}-featureName`, scope, feature.name);
@@ -55,10 +61,14 @@ class EvidentlyManager {
55
61
  * @param props the launch properties
56
62
  */
57
63
  createLaunch(id, scope, props) {
64
+ if (!props)
65
+ throw `EvidentlyLaunch props undefined for ${id}`;
66
+ if (!props.name)
67
+ throw `EvidentlyLaunch name undefined for ${id}`;
58
68
  const launch = new aws_evidently_1.CfnLaunch(scope, `${id}`, {
59
69
  ...props,
60
70
  description: `${props.description} ${scope.props.stage}`,
61
- name: `${props.name}-${scope.props.stage}`,
71
+ name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
62
72
  });
63
73
  (0, utils_1.createCfnOutput)(`${id}-launchArn`, scope, launch.attrArn);
64
74
  (0, utils_1.createCfnOutput)(`${id}-launchName`, scope, launch.name);
@@ -71,10 +81,14 @@ class EvidentlyManager {
71
81
  * @param props the experiment properties
72
82
  */
73
83
  createExperiment(id, scope, props) {
84
+ if (!props)
85
+ throw `EvidentlyExperiment props undefined for ${id}`;
86
+ if (!props.name)
87
+ throw `EvidentlyExperiment name undefined for ${id}`;
74
88
  const experiment = new aws_evidently_1.CfnExperiment(scope, `${id}`, {
75
89
  ...props,
76
90
  description: `${props.description} ${scope.props.stage}`,
77
- name: `${props.name}-${scope.props.stage}`,
91
+ name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
78
92
  });
79
93
  (0, utils_1.createCfnOutput)(`${id}-experimentArn`, scope, experiment.attrArn);
80
94
  (0, utils_1.createCfnOutput)(`${id}-experimentName`, scope, experiment.name);
@@ -87,10 +101,14 @@ class EvidentlyManager {
87
101
  * @param props the segment properties
88
102
  */
89
103
  createSegment(id, scope, props) {
104
+ if (!props)
105
+ throw `EvidentlySegment props undefined for ${id}`;
106
+ if (!props.name)
107
+ throw `EvidentlySegment name undefined for ${id}`;
90
108
  const segment = new aws_evidently_1.CfnSegment(scope, `${id}`, {
91
109
  ...props,
92
110
  description: `${props.description} ${scope.props.stage}`,
93
- name: `${props.name}-${scope.props.stage}`,
111
+ name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
94
112
  });
95
113
  (0, utils_1.createCfnOutput)(`${id}-segmentArn`, scope, segment.attrArn);
96
114
  (0, utils_1.createCfnOutput)(`${id}-segmentName`, scope, segment.name);
@@ -1,7 +1,9 @@
1
1
  import { CfnExperimentProps, CfnFeatureProps, CfnLaunchProps, CfnProjectProps, CfnSegmentProps } from 'aws-cdk-lib/aws-evidently';
2
+ import { ResourceNameFormatterProps } from '../../common';
2
3
  /**
3
4
  */
4
5
  export interface EvidentlyProjectProps extends CfnProjectProps {
6
+ resourceNameOptions?: ResourceNameFormatterProps;
5
7
  }
6
8
  /**
7
9
  */
@@ -10,12 +12,15 @@ export interface EvidentlyFeatureProps extends CfnFeatureProps {
10
12
  /**
11
13
  */
12
14
  export interface EvidentlyLaunchProps extends CfnLaunchProps {
15
+ resourceNameOptions?: ResourceNameFormatterProps;
13
16
  }
14
17
  /**
15
18
  */
16
19
  export interface EvidentlyExperimentProps extends CfnExperimentProps {
20
+ resourceNameOptions?: ResourceNameFormatterProps;
17
21
  }
18
22
  /**
19
23
  */
20
24
  export interface EvidentlySegmentProps extends CfnSegmentProps {
25
+ resourceNameOptions?: ResourceNameFormatterProps;
21
26
  }
@@ -416,10 +416,10 @@ class IamManager {
416
416
  policies: [
417
417
  {
418
418
  policyDocument: policy,
419
- policyName: `${id}-policy-${scope.props.stage}`,
419
+ policyName: scope.resourceNameFormatter(`${id}-policy`),
420
420
  },
421
421
  ],
422
- roleName: `${id}-${scope.props.stage}`,
422
+ roleName: scope.resourceNameFormatter(id),
423
423
  });
424
424
  (0, utils_1.createCfnOutput)(`${id}Arn`, scope, role.attrArn);
425
425
  (0, utils_1.createCfnOutput)(`${id}Name`, scope, role.roleName);
@@ -440,7 +440,7 @@ class IamManager {
440
440
  assumedBy: new aws_iam_1.ServicePrincipal('events.amazonaws.com'),
441
441
  description: `Role for ${id} ECS Task execution from EventBridge`,
442
442
  inlinePolicies: { policy },
443
- roleName: `${id}-${scope.props.stage}`,
443
+ roleName: scope.resourceNameFormatter(id),
444
444
  });
445
445
  (0, utils_1.createCfnOutput)(`${id}Arn`, scope, role.roleArn);
446
446
  (0, utils_1.createCfnOutput)(`${id}Name`, scope, role.roleName);
@@ -460,7 +460,7 @@ class IamManager {
460
460
  managedPolicies: [
461
461
  aws_iam_1.ManagedPolicy.fromManagedPolicyArn(scope, `${id}-AmazonECSTaskExecutionRolePolicy`, 'arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy'),
462
462
  ],
463
- roleName: `${id}-${scope.props.stage}`,
463
+ roleName: scope.resourceNameFormatter(id),
464
464
  });
465
465
  (0, utils_1.createCfnOutput)(`${id}Arn`, scope, role.roleArn);
466
466
  (0, utils_1.createCfnOutput)(`${id}Name`, scope, role.roleName);
@@ -481,7 +481,7 @@ class IamManager {
481
481
  managedPolicies: [
482
482
  aws_iam_1.ManagedPolicy.fromManagedPolicyArn(scope, `${id}-AWSLambdaBasicExecutionRole`, 'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'),
483
483
  ],
484
- roleName: `${id}-${scope.props.stage}`,
484
+ roleName: scope.resourceNameFormatter(id),
485
485
  });
486
486
  (0, utils_1.createCfnOutput)(`${id}Arn`, scope, role.roleArn);
487
487
  (0, utils_1.createCfnOutput)(`${id}Name`, scope, role.roleName);
@@ -499,7 +499,7 @@ class IamManager {
499
499
  assumedBy: servicePrincipal ?? new aws_iam_1.ServicePrincipal('appconfig.amazonaws.com'),
500
500
  description: `Role for ${id} AppConfig Secrets`,
501
501
  inlinePolicies: { policy },
502
- roleName: `${id}-${scope.props.stage}`,
502
+ roleName: scope.resourceNameFormatter(id),
503
503
  });
504
504
  (0, utils_1.createCfnOutput)(`${id}Arn`, scope, role.roleArn);
505
505
  (0, utils_1.createCfnOutput)(`${id}Name`, scope, role.roleName);
@@ -520,7 +520,7 @@ class IamManager {
520
520
  managedPolicies: [
521
521
  aws_iam_1.ManagedPolicy.fromManagedPolicyArn(scope, `${id}-AWSLambdaBasicExecutionRole`, 'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'),
522
522
  ],
523
- roleName: `${id}-${scope.props.stage}`,
523
+ roleName: scope.resourceNameFormatter(id),
524
524
  });
525
525
  (0, utils_1.createCfnOutput)(`${id}Arn`, scope, role.roleArn);
526
526
  (0, utils_1.createCfnOutput)(`${id}Name`, scope, role.roleName);
@@ -537,7 +537,7 @@ class IamManager {
537
537
  const role = new aws_iam_1.Role(scope, `${id}`, {
538
538
  assumedBy: new aws_iam_1.ServicePrincipal('pipes.amazonaws.com'),
539
539
  description: `Role for ${id} Pipe`,
540
- roleName: `${id}-${scope.props.stage}`,
540
+ roleName: scope.resourceNameFormatter(id),
541
541
  });
542
542
  role.addToPolicy(this.statementForPollQueue([queueArn]));
543
543
  role.addToPolicy(this.statementForStartExecution([stepFunctionArn]));
@@ -556,7 +556,7 @@ class IamManager {
556
556
  const role = new aws_iam_1.Role(scope, `${id}`, {
557
557
  assumedBy: new aws_iam_1.ServicePrincipal('pipes.amazonaws.com'),
558
558
  description: `Role for ${id} Pipe`,
559
- roleName: `${id}-${scope.props.stage}`,
559
+ roleName: scope.resourceNameFormatter(id),
560
560
  });
561
561
  role.addToPolicy(this.statementForPollQueue([queueArn]));
562
562
  role.addToPolicy(this.statementForInvokeLambda([lambdaArn]));
@@ -600,7 +600,7 @@ class IamManager {
600
600
  const role = new aws_iam_1.Role(scope, `${id}`, {
601
601
  assumedBy: new aws_iam_1.ServicePrincipal('pipes.amazonaws.com'),
602
602
  description: `Role for ${id} Pipe`,
603
- roleName: `${id}-${scope.props.stage}`,
603
+ roleName: scope.resourceNameFormatter(id),
604
604
  });
605
605
  role.addToPolicy(this.statementFordynamoDbStream([dynamoDbStreamArn]));
606
606
  role.addToPolicy(this.statementForInvokeLambda([lambdaFunctionArn]));
@@ -74,7 +74,9 @@ class LambdaManager {
74
74
  createLambdaFunction(id, scope, props, role, layers, code, handler, environment, vpc, securityGroups, accessPoint, mountPath, vpcSubnets) {
75
75
  if (!props)
76
76
  throw `Lambda props undefined for ${id}`;
77
- const functionName = `${props.functionName}-${scope.props.stage}`;
77
+ if (!props.functionName)
78
+ throw `Lambda functionName undefined for ${id}`;
79
+ const functionName = scope.resourceNameFormatter(props.functionName, props.resourceNameOptions);
78
80
  let deadLetterQueue;
79
81
  if (props.deadLetterQueueEnabled) {
80
82
  const redriveQueue = scope.sqsManager.createRedriveQueueForLambda(`${id}-rdq`, scope, props);
@@ -177,7 +179,9 @@ class LambdaManager {
177
179
  createLambdaDockerFunction(id, scope, props, role, code, environment, vpc, securityGroups, accessPoint, mountPath, vpcSubnets) {
178
180
  if (!props)
179
181
  throw `Lambda props undefined for ${id}`;
180
- const functionName = `${props.functionName}-${scope.props.stage}`;
182
+ if (!props.functionName)
183
+ throw `Lambda functionName undefined for ${id}`;
184
+ const functionName = scope.resourceNameFormatter(props.functionName, props.resourceNameOptions);
181
185
  let deadLetterQueue;
182
186
  if (props.deadLetterQueueEnabled) {
183
187
  const redriveQueue = scope.sqsManager.createRedriveQueueForLambda(`${id}-rdq`, scope, props);
@@ -1,8 +1,9 @@
1
+ import { EdgeFunctionProps } from 'aws-cdk-lib/aws-cloudfront/lib/experimental';
1
2
  import { AliasProps, FunctionProps } from 'aws-cdk-lib/aws-lambda';
3
+ import { SqsEventSourceProps } from 'aws-cdk-lib/aws-lambda-event-sources';
4
+ import { ResourceNameFormatterProps } from '../../common';
2
5
  import { TagProps } from '../../types';
3
- import { EdgeFunctionProps } from 'aws-cdk-lib/aws-cloudfront/lib/experimental';
4
6
  import { QueueProps } from '../simple-queue-service';
5
- import { SqsEventSourceProps } from 'aws-cdk-lib/aws-lambda-event-sources';
6
7
  /**
7
8
  */
8
9
  export interface ProvisionedConcurrencyProps {
@@ -20,6 +21,7 @@ export interface LambdaProps extends FunctionProps {
20
21
  redriveq?: QueueProps;
21
22
  tags?: TagProps[];
22
23
  timeoutInSecs?: number;
24
+ resourceNameOptions?: ResourceNameFormatterProps;
23
25
  }
24
26
  /**
25
27
  */
@@ -32,6 +34,7 @@ export interface LambdaAliasProps extends AliasProps {
32
34
  export interface LambdaEdgeProps extends EdgeFunctionProps {
33
35
  tags?: TagProps[];
34
36
  timeoutInSecs?: number;
37
+ resourceNameOptions?: ResourceNameFormatterProps;
35
38
  }
36
39
  /**
37
40
  */
@@ -1 +1,2 @@
1
1
  export * from './main';
2
+ export * from './types';
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./main"), exports);
18
+ __exportStar(require("./types"), exports);
@@ -1,5 +1,6 @@
1
- import { Secret, SecretProps } from 'aws-cdk-lib/aws-secretsmanager';
1
+ import { Secret } from 'aws-cdk-lib/aws-secretsmanager';
2
2
  import { CommonConstruct } from '../../common';
3
+ import { SecretBaseProps } from './types';
3
4
  /**
4
5
  * @classdesc Provides operations on AWS Secrets Manager.
5
6
  * - A new instance of this class is injected into {@link CommonConstruct} constructor.
@@ -23,7 +24,7 @@ export declare class SecretsManager {
23
24
  * @param scope scope in which this resource is defined
24
25
  * @param props the secret properties
25
26
  */
26
- createSecret(id: string, scope: CommonConstruct, props: SecretProps): Secret;
27
+ createSecret(id: string, scope: CommonConstruct, props: SecretBaseProps): Secret;
27
28
  /**
28
29
  * @summary Method to retrieve a secret from secrets manager with a cloudformation export
29
30
  * @param id
@@ -29,9 +29,13 @@ class SecretsManager {
29
29
  * @param props the secret properties
30
30
  */
31
31
  createSecret(id, scope, props) {
32
+ if (!props)
33
+ throw `Secret props undefined for ${id}`;
34
+ if (!props.secretName)
35
+ throw `Secret name undefined for ${id}`;
32
36
  const secret = new aws_secretsmanager_1.Secret(scope, `${id}`, {
33
37
  ...props,
34
- secretName: `${props.secretName}-${scope.props.stage}`,
38
+ secretName: scope.resourceNameFormatter(props.secretName, props.resourceNameOptions),
35
39
  });
36
40
  (0, utils_1.createCfnOutput)(`${id}-secretName`, scope, secret.secretName);
37
41
  (0, utils_1.createCfnOutput)(`${id}-secretArn`, scope, secret.secretArn);
@@ -0,0 +1,5 @@
1
+ import { SecretProps } from 'aws-cdk-lib/aws-secretsmanager';
2
+ import { ResourceNameFormatterProps } from '../../common';
3
+ export interface SecretBaseProps extends SecretProps {
4
+ resourceNameOptions?: ResourceNameFormatterProps;
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -35,10 +35,12 @@ class SnsManager {
35
35
  createEmailNotificationService(id, scope, props, emails) {
36
36
  if (!props)
37
37
  throw `Subscription props undefined for ${id}`;
38
+ if (!props.topicName)
39
+ throw `Subscription topicName undefined for ${id}`;
38
40
  const topic = new aws_sns_1.Topic(scope, id, {
39
41
  ...props,
40
- displayName: `${props.topicName}-${scope.props.stage}`,
41
- topicName: `${props.topicName}-${scope.props.stage}`,
42
+ displayName: scope.resourceNameFormatter(props.topicName, props.resourceNameOptions),
43
+ topicName: scope.resourceNameFormatter(props.topicName, props.resourceNameOptions),
42
44
  });
43
45
  if (emails && !lodash_1.default.isEmpty(emails)) {
44
46
  lodash_1.default.forEach(emails, (email) => topic.addSubscription(new aws_sns_subscriptions_1.EmailSubscription(email)));
@@ -57,10 +59,12 @@ class SnsManager {
57
59
  createLambdaNotificationService(id, scope, props, lambdaFunction) {
58
60
  if (!props)
59
61
  throw `Subscription props undefined for ${id}`;
62
+ if (!props.topicName)
63
+ throw `Subscription topicName undefined for ${id}`;
60
64
  const topic = new aws_sns_1.Topic(scope, id, {
61
65
  ...props,
62
- displayName: `${props.topicName}-${scope.props.stage}`,
63
- topicName: `${props.topicName}-${scope.props.stage}`,
66
+ displayName: scope.resourceNameFormatter(props.topicName, props.resourceNameOptions),
67
+ topicName: scope.resourceNameFormatter(props.topicName, props.resourceNameOptions),
64
68
  });
65
69
  topic.addSubscription(new aws_sns_subscriptions_1.LambdaSubscription(lambdaFunction));
66
70
  (0, utils_1.createCfnOutput)(`${id}-subscriptionArn`, scope, topic.topicArn);
@@ -1,5 +1,7 @@
1
1
  import { TopicProps } from 'aws-cdk-lib/aws-sns';
2
+ import { ResourceNameFormatterProps } from '../../common';
2
3
  /**
3
4
  */
4
5
  export interface SubscriptionProps extends TopicProps {
6
+ resourceNameOptions?: ResourceNameFormatterProps;
5
7
  }