@gradientedge/cdk-utils 9.8.0 → 9.10.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 (111) 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 +3 -1
  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 +1 -1
  12. package/dist/src/lib/aws/construct/lambda-with-iam-access/main.js +4 -5
  13. package/dist/src/lib/aws/construct/site-with-ecs-backend/main.js +13 -9
  14. package/dist/src/lib/aws/construct/site-with-lambda-backend/main.js +9 -3
  15. package/dist/src/lib/aws/services/api-gateway/main.js +3 -1
  16. package/dist/src/lib/aws/services/api-gateway/types.d.ts +6 -1
  17. package/dist/src/lib/aws/services/appconfig/main.js +1 -1
  18. package/dist/src/lib/aws/services/appconfig/types.d.ts +2 -0
  19. package/dist/src/lib/aws/services/cloudfront/main.js +8 -2
  20. package/dist/src/lib/aws/services/cloudfront/types.d.ts +2 -0
  21. package/dist/src/lib/aws/services/cloudtrail/main.js +3 -1
  22. package/dist/src/lib/aws/services/cloudtrail/types.d.ts +2 -0
  23. package/dist/src/lib/aws/services/dynamodb/main.js +3 -1
  24. package/dist/src/lib/aws/services/dynamodb/types.d.ts +2 -0
  25. package/dist/src/lib/aws/services/elastic-container-service/main.js +6 -2
  26. package/dist/src/lib/aws/services/elastic-container-service/types.d.ts +2 -0
  27. package/dist/src/lib/aws/services/elastic-file-system/main.js +3 -1
  28. package/dist/src/lib/aws/services/elastic-file-system/types.d.ts +3 -1
  29. package/dist/src/lib/aws/services/elastic-kubernetes-service/main.js +3 -1
  30. package/dist/src/lib/aws/services/elastic-kubernetes-service/types.d.ts +2 -0
  31. package/dist/src/lib/aws/services/elasticache/main.js +3 -1
  32. package/dist/src/lib/aws/services/elasticache/types.d.ts +2 -0
  33. package/dist/src/lib/aws/services/eventbridge/main.js +34 -9
  34. package/dist/src/lib/aws/services/eventbridge/types.d.ts +9 -1
  35. package/dist/src/lib/aws/services/evidently/main.js +22 -4
  36. package/dist/src/lib/aws/services/evidently/types.d.ts +5 -0
  37. package/dist/src/lib/aws/services/identity-access-management/main.js +10 -10
  38. package/dist/src/lib/aws/services/lambda/main.js +6 -2
  39. package/dist/src/lib/aws/services/lambda/types.d.ts +5 -2
  40. package/dist/src/lib/aws/services/secrets-manager/index.d.ts +1 -0
  41. package/dist/src/lib/aws/services/secrets-manager/index.js +1 -0
  42. package/dist/src/lib/aws/services/secrets-manager/main.d.ts +3 -2
  43. package/dist/src/lib/aws/services/secrets-manager/main.js +5 -1
  44. package/dist/src/lib/aws/services/secrets-manager/types.d.ts +5 -0
  45. package/dist/src/lib/aws/services/secrets-manager/types.js +2 -0
  46. package/dist/src/lib/aws/services/simple-notification-service/main.js +8 -4
  47. package/dist/src/lib/aws/services/simple-notification-service/types.d.ts +2 -0
  48. package/dist/src/lib/aws/services/simple-queue-service/main.js +9 -7
  49. package/dist/src/lib/aws/services/simple-queue-service/types.d.ts +2 -0
  50. package/dist/src/lib/aws/services/simple-storage-service/main.d.ts +1 -1
  51. package/dist/src/lib/aws/services/simple-storage-service/main.js +12 -8
  52. package/dist/src/lib/aws/services/simple-storage-service/types.d.ts +3 -1
  53. package/dist/src/lib/aws/services/step-function/main.js +3 -1
  54. package/dist/src/lib/aws/services/step-function/types.d.ts +2 -0
  55. package/dist/src/lib/aws/services/virtual-private-cloud/main.js +10 -3
  56. package/dist/src/lib/aws/services/virtual-private-cloud/types.d.ts +2 -0
  57. package/dist/src/lib/aws/services/web-application-firewall/main.js +6 -2
  58. package/dist/src/lib/aws/services/web-application-firewall/types.d.ts +3 -0
  59. package/package.json +17 -17
  60. package/src/lib/aws/common/construct.ts +16 -1
  61. package/src/lib/aws/common/stack.ts +3 -0
  62. package/src/lib/aws/common/types.ts +9 -0
  63. package/src/lib/aws/construct/api-to-any-target/main.ts +6 -1
  64. package/src/lib/aws/construct/api-to-any-target/types.ts +2 -3
  65. package/src/lib/aws/construct/api-to-eventbridge-target/main.ts +7 -1
  66. package/src/lib/aws/construct/api-to-eventbridge-target/types.ts +6 -7
  67. package/src/lib/aws/construct/api-to-eventbridge-target-with-sns/main.ts +7 -2
  68. package/src/lib/aws/construct/api-to-lambda-target/main.ts +1 -1
  69. package/src/lib/aws/construct/lambda-with-iam-access/main.ts +5 -5
  70. package/src/lib/aws/construct/site-with-ecs-backend/main.ts +15 -9
  71. package/src/lib/aws/construct/site-with-lambda-backend/main.ts +11 -3
  72. package/src/lib/aws/services/api-gateway/main.ts +3 -1
  73. package/src/lib/aws/services/api-gateway/types.ts +7 -1
  74. package/src/lib/aws/services/appconfig/main.ts +1 -1
  75. package/src/lib/aws/services/appconfig/types.ts +2 -0
  76. package/src/lib/aws/services/cloudfront/main.ts +6 -2
  77. package/src/lib/aws/services/cloudfront/types.ts +2 -0
  78. package/src/lib/aws/services/cloudtrail/main.ts +2 -1
  79. package/src/lib/aws/services/cloudtrail/types.ts +4 -1
  80. package/src/lib/aws/services/dynamodb/main.ts +2 -1
  81. package/src/lib/aws/services/dynamodb/types.ts +4 -1
  82. package/src/lib/aws/services/elastic-container-service/main.ts +4 -2
  83. package/src/lib/aws/services/elastic-container-service/types.ts +2 -0
  84. package/src/lib/aws/services/elastic-file-system/main.ts +2 -1
  85. package/src/lib/aws/services/elastic-file-system/types.ts +3 -1
  86. package/src/lib/aws/services/elastic-kubernetes-service/main.ts +2 -1
  87. package/src/lib/aws/services/elastic-kubernetes-service/types.ts +2 -0
  88. package/src/lib/aws/services/elasticache/main.ts +2 -1
  89. package/src/lib/aws/services/elasticache/types.ts +4 -1
  90. package/src/lib/aws/services/eventbridge/main.ts +28 -9
  91. package/src/lib/aws/services/eventbridge/types.ts +11 -2
  92. package/src/lib/aws/services/evidently/main.ts +18 -4
  93. package/src/lib/aws/services/evidently/types.ts +13 -4
  94. package/src/lib/aws/services/identity-access-management/main.ts +10 -10
  95. package/src/lib/aws/services/lambda/main.ts +4 -2
  96. package/src/lib/aws/services/lambda/types.ts +5 -2
  97. package/src/lib/aws/services/secrets-manager/index.ts +1 -0
  98. package/src/lib/aws/services/secrets-manager/main.ts +7 -3
  99. package/src/lib/aws/services/secrets-manager/types.ts +6 -0
  100. package/src/lib/aws/services/simple-notification-service/main.ts +6 -4
  101. package/src/lib/aws/services/simple-notification-service/types.ts +4 -1
  102. package/src/lib/aws/services/simple-queue-service/main.ts +8 -7
  103. package/src/lib/aws/services/simple-queue-service/types.ts +2 -0
  104. package/src/lib/aws/services/simple-storage-service/main.ts +12 -8
  105. package/src/lib/aws/services/simple-storage-service/types.ts +3 -1
  106. package/src/lib/aws/services/step-function/main.ts +3 -1
  107. package/src/lib/aws/services/step-function/types.ts +4 -1
  108. package/src/lib/aws/services/virtual-private-cloud/main.ts +9 -3
  109. package/src/lib/aws/services/virtual-private-cloud/types.ts +2 -0
  110. package/src/lib/aws/services/web-application-firewall/main.ts +4 -2
  111. package/src/lib/aws/services/web-application-firewall/types.ts +7 -2
@@ -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,11 @@ 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}`;
40
42
  const eventBus = new aws_events_1.EventBus(scope, `${id}`, {
41
43
  ...props,
42
- eventBusName: `${props.eventBusName}-${scope.props.stage}`,
44
+ eventBusName: scope.resourceNameFormatter(props.eventBusName, props.resourceNameOptions),
43
45
  });
44
46
  (0, utils_1.createCfnOutput)(`${id}-eventBusName`, scope, `${props.eventBusName}-${scope.props.stage}`);
45
47
  (0, utils_1.createCfnOutput)(`${id}-eventBusArn`, scope, eventBus.eventBusArn);
@@ -56,10 +58,12 @@ class EventManager {
56
58
  createRule(id, scope, props, eventBus, targets) {
57
59
  if (!props)
58
60
  throw `EventRule props undefined for ${id}`;
61
+ if (!props.ruleName)
62
+ throw `EventRule ruleName undefined for ${id}`;
59
63
  const rule = new aws_events_1.Rule(scope, `${id}`, {
60
64
  ...props,
61
65
  eventBus,
62
- ruleName: `${props.ruleName}-${scope.props.stage}`,
66
+ ruleName: scope.resourceNameFormatter(props.ruleName, props.resourceNameOptions),
63
67
  });
64
68
  if (targets && !lodash_1.default.isEmpty(targets)) {
65
69
  lodash_1.default.forEach(targets, target => {
@@ -88,21 +92,28 @@ class EventManager {
88
92
  createLambdaRule(id, scope, props, lambdaFunction, eventBusName, eventPattern, scheduleExpression) {
89
93
  if (!props)
90
94
  throw `EventRule props undefined for ${id}`;
95
+ if (!props.name)
96
+ throw `EventRule name undefined for ${id}`;
91
97
  const eventRule = new aws_events_1.CfnRule(scope, `${id}`, {
92
98
  ...props,
93
99
  description: 'Rule to send notification to lambda function target',
94
100
  eventBusName,
95
101
  eventPattern,
96
- name: `${props.name}-${scope.props.stage}`,
102
+ name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
97
103
  scheduleExpression,
98
104
  targets: [
99
105
  {
100
106
  arn: lambdaFunction.functionArn,
101
- id: `${id}-${scope.props.stage}`,
107
+ id: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
102
108
  input: props.input ?? undefined,
103
109
  },
104
110
  ],
105
111
  });
112
+ if (props.tags && !lodash_1.default.isEmpty(props.tags)) {
113
+ lodash_1.default.forEach(props.tags, tag => {
114
+ aws_cdk_lib_1.Tags.of(eventRule).add(tag.key, tag.value);
115
+ });
116
+ }
106
117
  new aws_lambda_1.CfnPermission(scope, `${id}LambdaPermission`, {
107
118
  action: 'lambda:InvokeFunction',
108
119
  functionName: lambdaFunction.functionName,
@@ -127,11 +138,13 @@ class EventManager {
127
138
  createFargateTaskRule(id, scope, props, cluster, task, subnetIds, role, eventPattern) {
128
139
  if (!props)
129
140
  throw `EventRule props undefined for ${id}`;
141
+ if (!props.name)
142
+ throw `EventRule name undefined for ${id}`;
130
143
  const eventRule = new aws_events_1.CfnRule(scope, `${id}`, {
131
144
  ...props,
132
145
  description: 'Rule to send notification on new objects in data bucket to ecs task target',
133
146
  eventPattern,
134
- name: `${props.name}-${scope.props.stage}`,
147
+ name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
135
148
  targets: [
136
149
  {
137
150
  arn: cluster.clusterArn,
@@ -143,7 +156,7 @@ class EventManager {
143
156
  taskCount: 1,
144
157
  taskDefinitionArn: task.taskDefinitionArn,
145
158
  },
146
- id: `${id}-${scope.props.stage}`,
159
+ id: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
147
160
  roleArn: role instanceof aws_iam_1.Role ? role.roleArn : role.attrArn,
148
161
  },
149
162
  ],
@@ -161,10 +174,14 @@ class EventManager {
161
174
  * @param targetStepFunction the target step function
162
175
  */
163
176
  createSqsToSfnCfnPipe(id, scope, props, sourceQueue, targetStepFunction) {
177
+ if (!props)
178
+ throw `Pipe props undefined for ${id}`;
179
+ if (!props.name)
180
+ throw `Pipe name undefined for ${id}`;
164
181
  const pipeRole = scope.iamManager.createRoleForSqsToSfnPipe(`${id}-role`, scope, sourceQueue.queueArn, targetStepFunction.stateMachineArn);
165
182
  const pipe = new aws_pipes_1.CfnPipe(scope, `${id}`, {
166
183
  ...props,
167
- name: `${props.name}-${scope.props.stage}`,
184
+ name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
168
185
  roleArn: pipeRole.roleArn,
169
186
  source: sourceQueue.queueArn,
170
187
  sourceParameters: {
@@ -203,10 +220,14 @@ class EventManager {
203
220
  * @param targetLambdaFunction the target lambda function
204
221
  */
205
222
  createSqsToLambdaCfnPipe(id, scope, props, sourceQueue, targetLambdaFunction) {
223
+ if (!props)
224
+ throw `Pipe props undefined for ${id}`;
225
+ if (!props.name)
226
+ throw `Pipe name undefined for ${id}`;
206
227
  const pipeRole = scope.iamManager.createRoleForSqsToLambdaPipe(`${id}-role`, scope, sourceQueue.queueArn, targetLambdaFunction.functionArn);
207
228
  const pipe = new aws_pipes_1.CfnPipe(scope, `${id}`, {
208
229
  ...props,
209
- name: `${props.name}-${scope.props.stage}`,
230
+ name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
210
231
  roleArn: pipeRole.roleArn,
211
232
  source: sourceQueue.queueArn,
212
233
  sourceParameters: {
@@ -242,10 +263,14 @@ class EventManager {
242
263
  * @param targetLambdaFunction the target lambda function
243
264
  */
244
265
  createDynamoDbToLambdaCfnPipe(id, scope, props, sourceDynamoDbStreamArn, targetLambdaFunction) {
266
+ if (!props)
267
+ throw `Pipe props undefined for ${id}`;
268
+ if (!props.name)
269
+ throw `Pipe name undefined for ${id}`;
245
270
  const pipeRole = scope.iamManager.createRoleForDynamoDbToLambdaPipe(`${id}-role`, scope, sourceDynamoDbStreamArn, targetLambdaFunction.functionArn);
246
271
  const pipe = new aws_pipes_1.CfnPipe(scope, `${id}`, {
247
272
  ...props,
248
- name: `${props.name}-${scope.props.stage}`,
273
+ name: scope.resourceNameFormatter(props.name, props.resourceNameOptions),
249
274
  roleArn: pipeRole.roleArn,
250
275
  source: sourceDynamoDbStreamArn,
251
276
  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
  }
@@ -35,6 +35,11 @@ class SqsManager {
35
35
  createQueue(id, scope, props, deadLetterQueue) {
36
36
  if (!props)
37
37
  throw `Queue props undefined for ${id}`;
38
+ if (!props.queueName)
39
+ throw `Queue queueName undefined for ${id}`;
40
+ let queueName = scope.resourceNameFormatter(props.queueName, props.resourceNameOptions);
41
+ if (props.fifo)
42
+ queueName += '.fifo';
38
43
  const queue = new aws_sqs_1.Queue(scope, id, {
39
44
  ...props,
40
45
  dataKeyReuse: props.dataKeyReuseInSecs ? aws_cdk_lib_1.Duration.seconds(props.dataKeyReuseInSecs) : props.dataKeyReuse,
@@ -45,6 +50,7 @@ class SqsManager {
45
50
  queue: deadLetterQueue,
46
51
  },
47
52
  deliveryDelay: props.deliveryDelayInSecs ? aws_cdk_lib_1.Duration.seconds(props.deliveryDelayInSecs) : undefined,
53
+ queueName,
48
54
  receiveMessageWaitTime: props.receiveMessageWaitTimeInSecs
49
55
  ? aws_cdk_lib_1.Duration.seconds(props.receiveMessageWaitTimeInSecs)
50
56
  : props.receiveMessageWaitTime,
@@ -73,9 +79,7 @@ class SqsManager {
73
79
  createRedriveQueueForLambda(id, scope, props) {
74
80
  return this.createQueue(`${id}`, scope, {
75
81
  ...props.redriveq,
76
- queueName: props.redriveq?.fifo
77
- ? `${props.functionName}-redriveq-${scope.props.stage}.fifo`
78
- : `${props.functionName}-redriveq-${scope.props.stage}`,
82
+ queueName: `${props.functionName}-redriveq`,
79
83
  });
80
84
  }
81
85
  /**
@@ -90,14 +94,12 @@ class SqsManager {
90
94
  if (props.dlq) {
91
95
  queueProps = {
92
96
  ...props.dlq,
93
- queueName: props.dlq.fifo
94
- ? `${props.functionName}-dlq-${scope.props.stage}.fifo`
95
- : `${props.functionName}-dlq-${scope.props.stage}`,
97
+ queueName: `${props.functionName}-dlq`,
96
98
  };
97
99
  }
98
100
  else {
99
101
  queueProps = {
100
- queueName: `${props.functionName}-dlq-${scope.props.stage}`,
102
+ queueName: `${props.functionName}-dlq`,
101
103
  };
102
104
  }
103
105
  return this.createQueue(`${id}`, scope, queueProps, deadLetterQueue);
@@ -1,4 +1,5 @@
1
1
  import * as sqs from 'aws-cdk-lib/aws-sqs';
2
+ import { ResourceNameFormatterProps } from '../../common';
2
3
  import { TagProps } from '../../types';
3
4
  /**
4
5
  */
@@ -12,4 +13,5 @@ export interface QueueProps extends sqs.QueueProps {
12
13
  retryBatchSize?: number;
13
14
  tags?: TagProps[];
14
15
  visibilityTimeoutInSecs?: number;
16
+ resourceNameOptions?: ResourceNameFormatterProps;
15
17
  }
@@ -42,7 +42,7 @@ export declare class S3Manager {
42
42
  * @param scope scope in which this resource is defined
43
43
  * @param bucketName the bucket name
44
44
  */
45
- static determineBucketName(scope: CommonConstruct, bucketName: string): string;
45
+ static determineBucketName(scope: CommonConstruct, props: S3BucketProps, bucketName: string): string;
46
46
  /**
47
47
  * @summary Method to create a s3 bucket
48
48
  * @param id scoped id of the resource
@@ -69,10 +69,14 @@ class S3Manager {
69
69
  * @param scope scope in which this resource is defined
70
70
  * @param bucketName the bucket name
71
71
  */
72
- static determineBucketName(scope, bucketName) {
73
- return scope.props.excludeDomainNameForBuckets
74
- ? S3Manager.determineBucketNameByAccountAndRegion(scope, bucketName)
75
- : S3Manager.determineBucketNameByDomainName(scope, bucketName);
72
+ static determineBucketName(scope, props, bucketName) {
73
+ if (!scope.props.excludeDomainNameForBuckets) {
74
+ return S3Manager.determineBucketNameByDomainName(scope, bucketName);
75
+ }
76
+ if (!scope.props.excludeAccountNumberForBuckets) {
77
+ return S3Manager.determineBucketNameByAccountAndRegion(scope, bucketName);
78
+ }
79
+ return scope.resourceNameFormatter(bucketName, props.resourceNameOptions);
76
80
  }
77
81
  /**
78
82
  * @summary Method to create a s3 bucket
@@ -84,15 +88,15 @@ class S3Manager {
84
88
  if (!props)
85
89
  throw `S3 props undefined for ${id}`;
86
90
  let bucket;
87
- const bucketName = S3Manager.determineBucketName(scope, props.bucketName);
91
+ const bucketName = S3Manager.determineBucketName(scope, props, props.bucketName);
88
92
  if (props.existingBucket && props.bucketName) {
89
- bucket = aws_s3_1.Bucket.fromBucketName(scope, `${id}`, bucketName);
93
+ bucket = aws_s3_1.Bucket.fromBucketName(scope, `${id}`, S3Manager.determineBucketName(scope, props, props.bucketName));
90
94
  }
91
95
  else {
92
96
  let logBucket;
93
97
  if (props.logBucketName) {
94
- const logBucketName = S3Manager.determineBucketName(scope, props.logBucketName);
95
- logBucket = aws_s3_1.Bucket.fromBucketName(scope, `${id}-logs`, logBucketName);
98
+ const logBucketName = S3Manager.determineBucketName(scope, props, props.logBucketName);
99
+ logBucket = aws_s3_1.Bucket.fromBucketName(scope, `${id}-logs`, props.logBucketName);
96
100
  }
97
101
  bucket = new aws_s3_1.Bucket(scope, `${id}-bucket`, {
98
102
  ...props,