@gradientedge/cdk-utils 8.122.0 → 8.124.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 (61) hide show
  1. package/app/api-destined-function/node_modules/.bin/uuid +2 -2
  2. package/app/api-destined-function/package.json +1 -1
  3. package/dist/src/lib/aws/common/stack.js +5 -7
  4. package/dist/src/lib/aws/construct/api-to-any-target/main.js +24 -26
  5. package/dist/src/lib/aws/construct/api-to-eventbridge-target/main.js +85 -103
  6. package/dist/src/lib/aws/construct/api-to-eventbridge-target-with-sns/main.js +94 -120
  7. package/dist/src/lib/aws/construct/api-to-lambda-target/main.js +8 -10
  8. package/dist/src/lib/aws/construct/graphql-api-lambda/main.js +7 -3
  9. package/dist/src/lib/aws/construct/graphql-api-lambda-with-cache/main.js +5 -1
  10. package/dist/src/lib/aws/construct/lambda-with-iam-access/main.js +5 -1
  11. package/dist/src/lib/aws/construct/rest-api-lambda/main.js +7 -3
  12. package/dist/src/lib/aws/construct/rest-api-lambda-with-cache/main.js +5 -1
  13. package/dist/src/lib/aws/construct/site-with-ecs-backend/main.js +8 -6
  14. package/dist/src/lib/aws/construct/static-asset-deployment/main.js +5 -1
  15. package/dist/src/lib/aws/services/api-gateway/main.js +18 -10
  16. package/dist/src/lib/aws/services/cloudfront/main.js +11 -7
  17. package/dist/src/lib/aws/services/cloudwatch/logs.js +8 -4
  18. package/dist/src/lib/aws/services/cloudwatch/main.js +36 -78
  19. package/dist/src/lib/aws/services/dynamodb/main.js +6 -2
  20. package/dist/src/lib/aws/services/elastic-container-service/main.js +8 -4
  21. package/dist/src/lib/aws/services/elastic-file-system/main.js +5 -1
  22. package/dist/src/lib/aws/services/elasticache/main.js +6 -2
  23. package/dist/src/lib/aws/services/eventbridge/main.js +8 -4
  24. package/dist/src/lib/aws/services/lambda/main.js +7 -3
  25. package/dist/src/lib/aws/services/simple-notification-service/main.js +6 -2
  26. package/dist/src/lib/aws/services/simple-queue-service/main.js +6 -2
  27. package/dist/src/lib/aws/services/simple-storage-service/main.js +8 -4
  28. package/dist/src/lib/aws/services/step-function/main.js +52 -32
  29. package/dist/src/lib/aws/services/virtual-private-cloud/main.js +8 -4
  30. package/dist/src/lib/azure/common/stack.js +5 -7
  31. package/dist/src/lib/common/index.js +7 -3
  32. package/package.json +16 -16
  33. package/src/lib/aws/common/stack.ts +5 -7
  34. package/src/lib/aws/construct/api-to-any-target/main.ts +25 -27
  35. package/src/lib/aws/construct/api-to-eventbridge-target/main.ts +85 -103
  36. package/src/lib/aws/construct/api-to-eventbridge-target-with-sns/main.ts +94 -120
  37. package/src/lib/aws/construct/api-to-lambda-target/main.ts +8 -10
  38. package/src/lib/aws/construct/graphql-api-lambda/main.ts +4 -3
  39. package/src/lib/aws/construct/graphql-api-lambda-with-cache/main.ts +2 -1
  40. package/src/lib/aws/construct/lambda-with-iam-access/main.ts +2 -1
  41. package/src/lib/aws/construct/rest-api-lambda/main.ts +4 -3
  42. package/src/lib/aws/construct/rest-api-lambda-with-cache/main.ts +2 -1
  43. package/src/lib/aws/construct/site-with-ecs-backend/main.ts +8 -9
  44. package/src/lib/aws/construct/static-asset-deployment/main.ts +2 -1
  45. package/src/lib/aws/services/api-gateway/main.ts +9 -6
  46. package/src/lib/aws/services/cloudfront/main.ts +8 -7
  47. package/src/lib/aws/services/cloudwatch/logs.ts +6 -5
  48. package/src/lib/aws/services/cloudwatch/main.ts +35 -81
  49. package/src/lib/aws/services/dynamodb/main.ts +3 -2
  50. package/src/lib/aws/services/elastic-container-service/main.ts +5 -4
  51. package/src/lib/aws/services/elastic-file-system/main.ts +2 -1
  52. package/src/lib/aws/services/elasticache/main.ts +3 -2
  53. package/src/lib/aws/services/eventbridge/main.ts +5 -4
  54. package/src/lib/aws/services/lambda/main.ts +4 -3
  55. package/src/lib/aws/services/simple-notification-service/main.ts +3 -2
  56. package/src/lib/aws/services/simple-queue-service/main.ts +3 -2
  57. package/src/lib/aws/services/simple-storage-service/main.ts +5 -4
  58. package/src/lib/aws/services/step-function/main.ts +17 -16
  59. package/src/lib/aws/services/virtual-private-cloud/main.ts +5 -4
  60. package/src/lib/azure/common/stack.ts +7 -9
  61. package/src/lib/common/index.ts +5 -3
@@ -5,6 +5,7 @@ import { AssetCode, IFunction, ILayerVersion, LayerVersion } from 'aws-cdk-lib/a
5
5
  import { IHostedZone } from 'aws-cdk-lib/aws-route53'
6
6
  import { ISecret } from 'aws-cdk-lib/aws-secretsmanager'
7
7
  import { Construct } from 'constructs'
8
+ import _ from 'lodash'
8
9
  import { CommonConstruct } from '../../common'
9
10
  import { RestApiLambdaEnvironment, RestApiLambdaProps } from './types'
10
11
 
@@ -152,7 +153,7 @@ export abstract class RestApiLambda extends CommonConstruct {
152
153
 
153
154
  if (!this.props.restApiLambdaLayerSources) return
154
155
 
155
- this.props.restApiLambdaLayerSources.forEach((source: AssetCode, index: number) => {
156
+ _.forEach(this.props.restApiLambdaLayerSources, (source: AssetCode, index: number) => {
156
157
  layers.push(this.lambdaManager.createLambdaLayer(`${this.id}-layer-${index}`, this, source))
157
158
  })
158
159
 
@@ -208,8 +209,8 @@ export abstract class RestApiLambda extends CommonConstruct {
208
209
  */
209
210
  protected createApiBasePathMapping() {
210
211
  const apiRootPaths = this.props.apiRootPaths
211
- if (apiRootPaths && apiRootPaths.length > 0) {
212
- apiRootPaths.forEach((apiRootPath: string) => {
212
+ if (apiRootPaths && !_.isEmpty(apiRootPaths)) {
213
+ _.forEach(apiRootPaths, (apiRootPath: string) => {
213
214
  this.restApiBasePathMappings.push(
214
215
  new BasePathMapping(this, `${this.id}-base-bath-mapping-${apiRootPath}`, {
215
216
  basePath: apiRootPath,
@@ -3,6 +3,7 @@ import { ISecurityGroup, IVpc, Peer, Port, SecurityGroup } from 'aws-cdk-lib/aws
3
3
  import { CfnReplicationGroup } from 'aws-cdk-lib/aws-elasticache'
4
4
  import { ManagedPolicy } from 'aws-cdk-lib/aws-iam'
5
5
  import { Construct } from 'constructs'
6
+ import _ from 'lodash'
6
7
  import { RestApiLambda } from '..'
7
8
  import { createCfnOutput } from '../../utils'
8
9
  import { RestApiLambdaWithCacheProps } from './types'
@@ -94,7 +95,7 @@ export abstract class RestApiLambdaWithCache extends RestApiLambda {
94
95
  `${this.id}-elasticache`,
95
96
  this,
96
97
  this.props.restApiCache,
97
- this.restApivpc.privateSubnets.map(subnet => subnet.subnetId),
98
+ _.map(this.restApivpc.privateSubnets, subnet => subnet.subnetId),
98
99
  [this.restApiSecurityGroup.securityGroupId]
99
100
  )
100
101
 
@@ -405,15 +405,14 @@ export class SiteWithEcsBackend extends CommonConstruct {
405
405
  name: `${this.id}-fs`,
406
406
  })
407
407
 
408
- if (this.props.siteTask.mountPoints && this.props.siteTask.mountPoints.length > 0) {
409
- this.props.siteTask.mountPoints.forEach(
410
- mountPoint =>
411
- this.siteEcsTaskDefinition.defaultContainer?.addMountPoints({
412
- containerPath: mountPoint.containerPath,
413
- readOnly: mountPoint.readOnly,
414
- sourceVolume: `${this.id}-fs`,
415
- })
416
- )
408
+ if (this.props.siteTask.mountPoints && !_.isEmpty(this.props.siteTask.mountPoints)) {
409
+ _.forEach(this.props.siteTask.mountPoints, mountPoint => {
410
+ this.siteEcsTaskDefinition.defaultContainer?.addMountPoints({
411
+ containerPath: mountPoint.containerPath,
412
+ readOnly: mountPoint.readOnly,
413
+ sourceVolume: `${this.id}-fs`,
414
+ })
415
+ })
417
416
  }
418
417
  }
419
418
 
@@ -1,6 +1,7 @@
1
1
  import { IBucket } from 'aws-cdk-lib/aws-s3'
2
2
  import { BucketDeployment } from 'aws-cdk-lib/aws-s3-deployment'
3
3
  import { Construct } from 'constructs'
4
+ import _ from 'lodash'
4
5
  import { CommonConstruct } from '../../common'
5
6
  import { StaticAssetDeploymentProps } from './types'
6
7
 
@@ -62,7 +63,7 @@ export class StaticAssetDeployment extends CommonConstruct {
62
63
  if (!staticAssetsForExport) return
63
64
 
64
65
  /* optional additional exports needed for asset urls */
65
- staticAssetsForExport.forEach(asset => {
66
+ _.forEach(staticAssetsForExport, asset => {
66
67
  this.addCfnOutput(asset.key, this.staticAssetBucket.s3UrlForObject(asset.value))
67
68
  })
68
69
  }
@@ -13,6 +13,7 @@ import {
13
13
  } from 'aws-cdk-lib/aws-apigateway'
14
14
  import { ICertificate } from 'aws-cdk-lib/aws-certificatemanager'
15
15
  import { IFunction } from 'aws-cdk-lib/aws-lambda'
16
+ import _ from 'lodash'
16
17
  import { CommonConstruct } from '../../common'
17
18
  import { createCfnOutput } from '../../utils'
18
19
  import { LambdaRestApiProps } from './types'
@@ -83,8 +84,8 @@ export class ApiManager {
83
84
  retainDeployments: props.retainDeployments,
84
85
  })
85
86
 
86
- if (props.tags && props.tags.length > 0) {
87
- props.tags.forEach(tag => {
87
+ if (props.tags && !_.isEmpty(props.tags)) {
88
+ _.forEach(props.tags, tag => {
88
89
  Tags.of(api).add(tag.key, tag.value)
89
90
  })
90
91
  }
@@ -153,12 +154,13 @@ export class ApiManager {
153
154
  allowOrigins: allowedOrigins ?? Cors.ALL_ORIGINS,
154
155
  },
155
156
  })
156
- methods.forEach(method =>
157
+
158
+ _.forEach(methods, method => {
157
159
  resource.addMethod(method, integration, {
158
160
  authorizer,
159
161
  requestParameters: methodRequestParameters,
160
162
  })
161
- )
163
+ })
162
164
  createCfnOutput(`${id}-${path}ResourceId`, scope, resource.resourceId)
163
165
 
164
166
  if (addProxy) {
@@ -170,12 +172,13 @@ export class ApiManager {
170
172
  allowOrigins: allowedOrigins ?? Cors.ALL_ORIGINS,
171
173
  },
172
174
  })
173
- methods.forEach(method =>
175
+
176
+ _.forEach(methods, method => {
174
177
  resourceProxy.addMethod(method, proxyIntegration ?? integration, {
175
178
  authorizer,
176
179
  requestParameters: methodRequestParameters,
177
180
  })
178
- )
181
+ })
179
182
  createCfnOutput(`${id}-${path}ProxyResourceId`, scope, resourceProxy.resourceId)
180
183
  }
181
184
 
@@ -26,6 +26,7 @@ import { CommonConstruct, CommonStack } from '../../common'
26
26
  import { createCfnOutput } from '../../utils'
27
27
  import { LambdaEdgeProps } from '../lambda'
28
28
  import { CloudFrontProps, CloudfrontFunctionProps, DistributionProps } from './types'
29
+ import _ from 'lodash'
29
30
 
30
31
  /**
31
32
  * @classdesc Provides operations on AWS
@@ -115,8 +116,8 @@ export class CloudFrontManager {
115
116
  webACLId: props.webACLId,
116
117
  })
117
118
 
118
- if (props.tags && props.tags.length > 0) {
119
- props.tags.forEach(tag => {
119
+ if (props.tags && !_.isEmpty(props.tags)) {
120
+ _.forEach(props.tags, tag => {
120
121
  Tags.of(distribution).add(tag.key, tag.value)
121
122
  })
122
123
  }
@@ -180,8 +181,8 @@ export class CloudFrontManager {
180
181
  webAclId: props.webAclId,
181
182
  })
182
183
 
183
- if (props.tags && props.tags.length > 0) {
184
- props.tags.forEach(tag => {
184
+ if (props.tags && !_.isEmpty(props.tags)) {
185
+ _.forEach(props.tags, tag => {
185
186
  Tags.of(distribution).add(tag.key, tag.value)
186
187
  })
187
188
  }
@@ -244,8 +245,8 @@ export class CloudFrontManager {
244
245
  webAclId: props.webAclId,
245
246
  })
246
247
 
247
- if (props.tags && props.tags.length > 0) {
248
- props.tags.forEach(tag => {
248
+ if (props.tags && !_.isEmpty(props.tags)) {
249
+ _.forEach(props.tags, tag => {
249
250
  Tags.of(distribution).add(tag.key, tag.value)
250
251
  })
251
252
  }
@@ -306,7 +307,7 @@ export class CloudFrontManager {
306
307
  vpc: vpc,
307
308
  })
308
309
 
309
- if (props.tags && props.tags.length > 0) {
310
+ if (props.tags && !_.isEmpty(props.tags)) {
310
311
  props.tags.forEach(tag => {
311
312
  Tags.of(edgeFunction).add(tag.key, tag.value)
312
313
  })
@@ -1,7 +1,8 @@
1
1
  import * as cdk from 'aws-cdk-lib'
2
2
  import * as logs from 'aws-cdk-lib/aws-logs'
3
- import * as utils from '../../utils'
3
+ import _ from 'lodash'
4
4
  import { CommonConstruct } from '../../common'
5
+ import * as utils from '../../utils'
5
6
  import { LogProps, MetricFilterProps } from './types'
6
7
 
7
8
  /**
@@ -66,8 +67,8 @@ export class LogManager {
66
67
  retentionInDays: props.retention,
67
68
  })
68
69
 
69
- if (props.tags && props.tags.length > 0) {
70
- props.tags.forEach(tag => {
70
+ if (props.tags && !_.isEmpty(props.tags)) {
71
+ _.forEach(props.tags, tag => {
71
72
  cdk.Tags.of(logGroup).add(tag.key, tag.value)
72
73
  })
73
74
  }
@@ -93,8 +94,8 @@ export class LogManager {
93
94
  retention: props.retention,
94
95
  })
95
96
 
96
- if (props.tags && props.tags.length > 0) {
97
- props.tags.forEach(tag => {
97
+ if (props.tags && !_.isEmpty(props.tags)) {
98
+ _.forEach(props.tags, tag => {
98
99
  cdk.Tags.of(logGroup).add(tag.key, tag.value)
99
100
  })
100
101
  }
@@ -1,8 +1,9 @@
1
1
  import * as cdk from 'aws-cdk-lib'
2
2
  import * as watch from 'aws-cdk-lib/aws-cloudwatch'
3
3
  import { IMetric } from 'aws-cdk-lib/aws-cloudwatch'
4
- import * as utils from '../../utils'
4
+ import _ from 'lodash'
5
5
  import { CommonConstruct } from '../../common'
6
+ import * as utils from '../../utils'
6
7
  import {
7
8
  AlarmProps,
8
9
  AlarmStatusWidgetProps,
@@ -56,9 +57,10 @@ export class CloudWatchManager {
56
57
  if (!props.metricProps) throw `Could not find metricProps for Alarm props for id:${id}`
57
58
 
58
59
  const metrics: any = {}
59
- this.determineMetrics(scope, props.metricProps).map(
60
- (metric: watch.IMetric, index: number) => (metrics[`m${index}`] = metric)
61
- )
60
+ _.map(this.determineMetrics(scope, props.metricProps), (metric: watch.IMetric, index: number) => {
61
+ metrics[`m${index}`] = metric
62
+ })
63
+
62
64
  const expression = new watch.MathExpression({
63
65
  expression: props.expression,
64
66
  period: props.periodInSecs ? cdk.Duration.seconds(props.periodInSecs) : cdk.Duration.minutes(5),
@@ -139,7 +141,9 @@ export class CloudWatchManager {
139
141
  if (!props || props.length == 0) throw `Widget props undefined`
140
142
 
141
143
  const widgets: any = []
142
- props.forEach((widgetProps: any) => widgets.push(this.createWidget(widgetProps.id, scope, widgetProps)))
144
+ _.forEach(props, (widgetProps: any) => {
145
+ widgets.push(this.createWidget(widgetProps.id, scope, widgetProps))
146
+ })
143
147
 
144
148
  return widgets
145
149
  }
@@ -188,9 +192,7 @@ export class CloudWatchManager {
188
192
  const metricProps: any[] = props.metricProps
189
193
  return this.createWidget(id, scope, {
190
194
  ...props,
191
- ...{
192
- metricProps: metricProps.map(metricProp => ({ ...metricProp, ...{ distributionId: distributionId } })),
193
- },
195
+ metricProps: _.map(metricProps, { ..._, distributionId }),
194
196
  })
195
197
  }
196
198
 
@@ -206,9 +208,7 @@ export class CloudWatchManager {
206
208
  const metricProps: any[] = props.metricProps
207
209
  return this.createWidget(id, scope, {
208
210
  ...props,
209
- ...{
210
- metricProps: metricProps.map(metricProp => ({ ...metricProp, ...{ stateMachineArn: stateMachineArn } })),
211
- },
211
+ metricProps: _.map(metricProps, { ..._, stateMachineArn }),
212
212
  })
213
213
  }
214
214
 
@@ -225,12 +225,7 @@ export class CloudWatchManager {
225
225
  const metricProps: any[] = props.metricProps
226
226
  return this.createWidget(id, scope, {
227
227
  ...props,
228
- ...{
229
- metricProps: metricProps.map(metricProp => ({
230
- ...metricProp,
231
- ...{ eventBusName: eventBusName, ruleName: ruleName },
232
- })),
233
- },
228
+ metricProps: _.map(metricProps, { ..._, eventBusName, ruleName }),
234
229
  })
235
230
  }
236
231
 
@@ -246,9 +241,7 @@ export class CloudWatchManager {
246
241
  const metricProps: any[] = props.metricProps
247
242
  return this.createWidget(id, scope, {
248
243
  ...props,
249
- ...{
250
- metricProps: metricProps.map(metricProp => ({ ...metricProp, ...{ apiName: apiName } })),
251
- },
244
+ metricProps: _.map(metricProps, { ..._, apiName }),
252
245
  })
253
246
  }
254
247
 
@@ -264,9 +257,7 @@ export class CloudWatchManager {
264
257
  const metricProps: any[] = props.metricProps
265
258
  return this.createWidget(id, scope, {
266
259
  ...props,
267
- ...{
268
- metricProps: metricProps.map(metricProp => ({ ...metricProp, ...{ functionName: functionName } })),
269
- },
260
+ metricProps: _.map(metricProps, { ..._, functionName }),
270
261
  })
271
262
  }
272
263
 
@@ -282,9 +273,7 @@ export class CloudWatchManager {
282
273
  const metricProps: any[] = props.metricProps
283
274
  return this.createWidget(id, scope, {
284
275
  ...props,
285
- ...{
286
- metricProps: metricProps.map(metricProp => ({ ...metricProp, ...{ service: service } })),
287
- },
276
+ metricProps: _.map(metricProps, { ..._, service }),
288
277
  })
289
278
  }
290
279
 
@@ -300,9 +289,7 @@ export class CloudWatchManager {
300
289
  const metricProps: any[] = props.metricProps
301
290
  return this.createWidget(id, scope, {
302
291
  ...props,
303
- ...{
304
- metricProps: metricProps.map(metricProp => ({ ...metricProp, ...{ clusterName: clusterName } })),
305
- },
292
+ metricProps: _.map(metricProps, { ..._, clusterName }),
306
293
  })
307
294
  }
308
295
 
@@ -325,12 +312,7 @@ export class CloudWatchManager {
325
312
  const metricProps: any[] = props.metricProps
326
313
  return this.createWidget(id, scope, {
327
314
  ...props,
328
- ...{
329
- metricProps: metricProps.map(metricProp => ({
330
- ...metricProp,
331
- ...{ clusterName: clusterName, serviceName: serviceName },
332
- })),
333
- },
315
+ metricProps: _.map(metricProps, { ..._, clusterName, serviceName }),
334
316
  })
335
317
  }
336
318
 
@@ -346,9 +328,7 @@ export class CloudWatchManager {
346
328
  const metricProps: any[] = props.metricProps
347
329
  return this.createWidget(id, scope, {
348
330
  ...props,
349
- ...{
350
- metricProps: metricProps.map(metricProp => ({ ...metricProp, ...{ loadBalancer: loadBalancer } })),
351
- },
331
+ metricProps: _.map(metricProps, { ..._, loadBalancer }),
352
332
  })
353
333
  }
354
334
 
@@ -364,9 +344,7 @@ export class CloudWatchManager {
364
344
  const metricProps: any[] = props.metricProps
365
345
  return this.createWidget(id, scope, {
366
346
  ...props,
367
- ...{
368
- metricProps: metricProps.map(metricProp => ({ ...metricProp, ...{ cacheClusterId: cacheClusterId } })),
369
- },
347
+ metricProps: _.map(metricProps, { ..._, cacheClusterId }),
370
348
  })
371
349
  }
372
350
 
@@ -541,101 +519,77 @@ export class CloudWatchManager {
541
519
  if (metricProp.functionName) {
542
520
  metricDimensions = {
543
521
  ...metricProp.dimensionsMap,
544
- ...{
545
- FunctionName: `${metricProp.functionName}`,
546
- },
522
+ FunctionName: `${metricProp.functionName}`,
547
523
  }
548
524
  }
549
525
  if (metricProp.serviceName && metricProp.clusterName) {
550
526
  metricDimensions = {
551
527
  ...metricProp.dimensionsMap,
552
- ...{
553
- ClusterName: `${metricProp.clusterName}`,
554
- ServiceName: `${metricProp.serviceName}`,
555
- },
528
+ ClusterName: `${metricProp.clusterName}`,
529
+ ServiceName: `${metricProp.serviceName}`,
556
530
  }
557
531
  }
558
532
  if (!metricProp.serviceName && metricProp.clusterName) {
559
533
  metricDimensions = {
560
534
  ...metricProp.dimensionsMap,
561
- ...{
562
- ClusterName: `${metricProp.clusterName}`,
563
- },
535
+ ClusterName: `${metricProp.clusterName}`,
564
536
  }
565
537
  }
566
538
  if (metricProp.serviceName && !metricProp.clusterName) {
567
539
  metricDimensions = {
568
540
  ...metricProp.dimensionsMap,
569
- ...{
570
- ServiceName: `${metricProp.serviceName}`,
571
- },
541
+ ServiceName: `${metricProp.serviceName}`,
572
542
  }
573
543
  }
574
544
  if (metricProp.loadBalancer) {
575
545
  metricDimensions = {
576
546
  ...metricProp.dimensionsMap,
577
- ...{
578
- LoadBalancer: `${metricProp.loadBalancer}`,
579
- },
547
+ LoadBalancer: `${metricProp.loadBalancer}`,
580
548
  }
581
549
  }
582
550
  if (metricProp.service) {
583
551
  metricDimensions = {
584
552
  ...metricProp.dimensionsMap,
585
- ...{
586
- service: `${metricProp.service}`,
587
- },
553
+ service: `${metricProp.service}`,
588
554
  }
589
555
  }
590
556
  if (metricProp.distributionId) {
591
557
  metricDimensions = {
592
558
  ...metricProp.dimensionsMap,
593
- ...{
594
- DistributionId: `${metricProp.distributionId}`,
595
- Region: `Global`,
596
- },
559
+ DistributionId: `${metricProp.distributionId}`,
560
+ Region: `Global`,
597
561
  }
598
562
  }
599
563
  if (metricProp.apiName) {
600
564
  metricDimensions = {
601
565
  ...metricProp.dimensionsMap,
602
- ...{
603
- ApiName: `${metricProp.apiName}`,
604
- },
566
+ ApiName: `${metricProp.apiName}`,
605
567
  }
606
568
  }
607
569
  if (metricProp.cacheClusterId) {
608
570
  metricDimensions = {
609
571
  ...metricProp.dimensionsMap,
610
- ...{
611
- CacheClusterId: `${metricProp.cacheClusterId}`,
612
- },
572
+ CacheClusterId: `${metricProp.cacheClusterId}`,
613
573
  }
614
574
  }
615
575
  if (metricProp.dbClusterIdentifier) {
616
576
  metricDimensions = {
617
577
  ...metricProp.dimensionsMap,
618
- ...{
619
- DBClusterIdentifier: `${metricProp.dbClusterIdentifier}`,
620
- },
578
+ DBClusterIdentifier: `${metricProp.dbClusterIdentifier}`,
621
579
  }
622
580
  }
623
581
  if (metricProp.stateMachineArn) {
624
582
  metricDimensions = {
625
583
  ...metricProp.dimensionsMap,
626
- ...{
627
- StateMachineArn: `${metricProp.stateMachineArn}`,
628
- },
584
+ StateMachineArn: `${metricProp.stateMachineArn}`,
629
585
  }
630
586
  }
631
587
 
632
588
  if (metricProp.eventBusName && metricProp.ruleName) {
633
589
  metricDimensions = {
634
590
  ...metricProp.dimensionsMap,
635
- ...{
636
- EventBusName: `${metricProp.eventBusName}`,
637
- RuleName: `${metricProp.ruleName}`,
638
- },
591
+ EventBusName: `${metricProp.eventBusName}`,
592
+ RuleName: `${metricProp.ruleName}`,
639
593
  }
640
594
  }
641
595
  const metric = new watch.Metric({
@@ -679,7 +633,7 @@ export class CloudWatchManager {
679
633
  private determineAlarms(id: string, scope: CommonConstruct, alarmProps: watch.AlarmProps[]) {
680
634
  const alarms: watch.IAlarm[] = []
681
635
  if (alarmProps) {
682
- alarmProps.forEach((alarmProp: watch.AlarmProps) => {
636
+ _.forEach(alarmProps, (alarmProp: watch.AlarmProps) => {
683
637
  if (!alarmProp.alarmName) throw `Alarm name undefined for ${id}`
684
638
  const alarmArn = `arn:aws:cloudwatch:${cdk.Stack.of(scope).region}:${cdk.Stack.of(scope).account}:alarm:${
685
639
  alarmProp.alarmName
@@ -1,5 +1,6 @@
1
1
  import { Tags } from 'aws-cdk-lib'
2
2
  import { Table } from 'aws-cdk-lib/aws-dynamodb'
3
+ import _ from 'lodash'
3
4
  import { CommonConstruct } from '../../common'
4
5
  import { createCfnOutput } from '../../utils'
5
6
  import { TableProps } from './types'
@@ -50,8 +51,8 @@ export class DynamodbManager {
50
51
  writeCapacity: props.writeCapacity,
51
52
  })
52
53
 
53
- if (props.tags && props.tags.length > 0) {
54
- props.tags.forEach(tag => {
54
+ if (props.tags && !_.isEmpty(props.tags)) {
55
+ _.forEach(props.tags, tag => {
55
56
  Tags.of(table).add(tag.key, tag.value)
56
57
  })
57
58
  }
@@ -14,6 +14,7 @@ import {
14
14
  import { ApplicationLoadBalancedFargateService } from 'aws-cdk-lib/aws-ecs-patterns'
15
15
  import { Role } from 'aws-cdk-lib/aws-iam'
16
16
  import { ILogGroup } from 'aws-cdk-lib/aws-logs'
17
+ import _ from 'lodash'
17
18
  import { CommonConstruct } from '../../common'
18
19
  import { createCfnOutput } from '../../utils'
19
20
  import { EcsApplicationLoadBalancedFargateServiceProps, EcsClusterProps, EcsTaskProps } from './types'
@@ -55,8 +56,8 @@ export class EcsManager {
55
56
  vpc: vpc,
56
57
  })
57
58
 
58
- if (props.tags && props.tags.length > 0) {
59
- props.tags.forEach(tag => {
59
+ if (props.tags && !_.isEmpty(props.tags)) {
60
+ _.forEach(props.tags, tag => {
60
61
  Tags.of(ecsCluster).add(tag.key, tag.value)
61
62
  })
62
63
  }
@@ -132,8 +133,8 @@ export class EcsManager {
132
133
  secrets: secrets,
133
134
  })
134
135
 
135
- if (props.tags && props.tags.length > 0) {
136
- props.tags.forEach(tag => {
136
+ if (props.tags && !_.isEmpty(props.tags)) {
137
+ _.forEach(props.tags, tag => {
137
138
  Tags.of(ecsTask).add(tag.key, tag.value)
138
139
  })
139
140
  }
@@ -1,6 +1,7 @@
1
1
  import { RemovalPolicy } from 'aws-cdk-lib'
2
2
  import { ISecurityGroup, IVpc, SubnetSelection } from 'aws-cdk-lib/aws-ec2'
3
3
  import { FileSystem, LifecyclePolicy, OutOfInfrequentAccessPolicy, PerformanceMode } from 'aws-cdk-lib/aws-efs'
4
+ import _ from 'lodash'
4
5
  import { CommonConstruct } from '../../common'
5
6
  import { createCfnOutput } from '../../utils'
6
7
  import { EfsAccessPointOptions, EfsFileSystemProps } from './types'
@@ -71,7 +72,7 @@ export class EfsManager {
71
72
  createCfnOutput(`${id}-fileSystemId`, scope, fileSystem.fileSystemId)
72
73
 
73
74
  /* provision access points if specified */
74
- if (accessPointOptions && accessPointOptions.length > 0) {
75
+ if (accessPointOptions && !_.isEmpty(accessPointOptions)) {
75
76
  for (const [index, accessPointOption] of accessPointOptions.entries()) {
76
77
  if (!accessPointOption.path) throw `Undefined access point path for option: [${accessPointOption}], id: [${id}]`
77
78
  const accessPoint = fileSystem.addAccessPoint(`${id}-ap-${index}`, {
@@ -1,5 +1,6 @@
1
1
  import { Tags } from 'aws-cdk-lib'
2
2
  import { CfnCacheCluster, CfnReplicationGroup, CfnSubnetGroup } from 'aws-cdk-lib/aws-elasticache'
3
+ import _ from 'lodash'
3
4
  import { CommonConstruct } from '../../common'
4
5
  import { createCfnOutput } from '../../utils'
5
6
  import { ElastiCacheProps, ReplicatedElastiCacheProps } from './types'
@@ -80,8 +81,8 @@ export class ElastiCacheManager {
80
81
 
81
82
  elasticacheCluster.addDependency(subnetGroup)
82
83
 
83
- if (props.tags && props.tags.length > 0) {
84
- props.tags.forEach(tag => {
84
+ if (props.tags && !_.isEmpty(props.tags)) {
85
+ _.forEach(props.tags, tag => {
85
86
  Tags.of(elasticacheCluster).add(tag.key, tag.value)
86
87
  })
87
88
  }
@@ -6,6 +6,7 @@ import { CfnPermission, IFunction } from 'aws-cdk-lib/aws-lambda'
6
6
  import { CfnPipe } from 'aws-cdk-lib/aws-pipes'
7
7
  import { IQueue } from 'aws-cdk-lib/aws-sqs'
8
8
  import { IStateMachine } from 'aws-cdk-lib/aws-stepfunctions'
9
+ import _ from 'lodash'
9
10
  import { CommonConstruct } from '../../common'
10
11
  import { createCfnOutput } from '../../utils'
11
12
  import { EventBusProps, EventRuleProps, RuleProps, SqsToSfnPipeProps } from './types'
@@ -72,14 +73,14 @@ export class EventManager {
72
73
  schedule: props.schedule,
73
74
  })
74
75
 
75
- if (targets && targets.length > 0) {
76
- targets.forEach(target => {
76
+ if (targets && !_.isEmpty(targets)) {
77
+ _.forEach(targets, target => {
77
78
  rule.addTarget(target)
78
79
  })
79
80
  }
80
81
 
81
- if (props.tags && props.tags.length > 0) {
82
- props.tags.forEach(tag => {
82
+ if (props.tags && !_.isEmpty(props.tags)) {
83
+ _.forEach(props.tags, tag => {
83
84
  Tags.of(rule).add(tag.key, tag.value)
84
85
  })
85
86
  }
@@ -15,6 +15,7 @@ import {
15
15
  LayerVersion,
16
16
  } from 'aws-cdk-lib/aws-lambda'
17
17
  import { SqsEventSource } from 'aws-cdk-lib/aws-lambda-event-sources'
18
+ import _ from 'lodash'
18
19
  import { CommonConstruct, CommonStack } from '../../common'
19
20
  import { createCfnOutput } from '../../utils'
20
21
  import { CloudFrontManager } from '../cloudfront'
@@ -144,7 +145,7 @@ export class LambdaManager {
144
145
  )
145
146
  }
146
147
 
147
- if (props.lambdaAliases && props.lambdaAliases.length > 0) {
148
+ if (props.lambdaAliases && !_.isEmpty(props.lambdaAliases)) {
148
149
  props.lambdaAliases.forEach(alias => {
149
150
  const aliasId = alias.id ?? `${id}-${alias.aliasName}`
150
151
  const functionAlias = this.createLambdaFunctionAlias(`${aliasId}`, scope, alias, lambdaFunction.currentVersion)
@@ -160,8 +161,8 @@ export class LambdaManager {
160
161
  })
161
162
  }
162
163
 
163
- if (props.tags && props.tags.length > 0) {
164
- props.tags.forEach(tag => {
164
+ if (props.tags && !_.isEmpty(props.tags)) {
165
+ _.forEach(props.tags, tag => {
165
166
  Tags.of(lambdaFunction).add(tag.key, tag.value)
166
167
  })
167
168
  }
@@ -1,6 +1,7 @@
1
1
  import { IFunction } from 'aws-cdk-lib/aws-lambda'
2
2
  import { Topic } from 'aws-cdk-lib/aws-sns'
3
3
  import { EmailSubscription, LambdaSubscription } from 'aws-cdk-lib/aws-sns-subscriptions'
4
+ import _ from 'lodash'
4
5
  import { CommonConstruct } from '../../common'
5
6
  import { createCfnOutput } from '../../utils'
6
7
  import { SubscriptionProps } from './types'
@@ -43,8 +44,8 @@ export class SnsManager {
43
44
  topicName: `${props.topicName}-${scope.props.stage}`,
44
45
  })
45
46
 
46
- if (emails && emails.length > 0) {
47
- emails.forEach((email: string) => topic.addSubscription(new EmailSubscription(email)))
47
+ if (emails && !_.isEmpty(emails)) {
48
+ _.forEach(emails, (email: string) => topic.addSubscription(new EmailSubscription(email)))
48
49
  }
49
50
 
50
51
  createCfnOutput(`${id}-subscriptionArn`, scope, topic.topicArn)