@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
@@ -1,5 +1,6 @@
1
1
  import { Duration, RemovalPolicy, Tags } from 'aws-cdk-lib'
2
2
  import { IQueue, Queue } from 'aws-cdk-lib/aws-sqs'
3
+ import _ from 'lodash'
3
4
  import { CommonConstruct } from '../../common'
4
5
  import { createCfnOutput } from '../../utils'
5
6
  import { LambdaProps } from '../lambda'
@@ -59,8 +60,8 @@ export class SqsManager {
59
60
  : props.visibilityTimeout,
60
61
  })
61
62
 
62
- if (props.tags && props.tags.length > 0) {
63
- props.tags.forEach(tag => {
63
+ if (props.tags && !_.isEmpty(props.tags)) {
64
+ _.forEach(props.tags, tag => {
64
65
  Tags.of(queue).add(tag.key, tag.value)
65
66
  })
66
67
  }
@@ -3,6 +3,7 @@ import { IDistribution } from 'aws-cdk-lib/aws-cloudfront'
3
3
  import { Effect, PolicyDocument, PolicyStatement, ServicePrincipal } from 'aws-cdk-lib/aws-iam'
4
4
  import { BlockPublicAccess, Bucket, BucketEncryption, CfnBucket, CfnBucketPolicy, IBucket } from 'aws-cdk-lib/aws-s3'
5
5
  import { BucketDeployment, ISource, ServerSideEncryption, Source } from 'aws-cdk-lib/aws-s3-deployment'
6
+ import _ from 'lodash'
6
7
  import { CommonConstruct } from '../../common'
7
8
  import { createCfnOutput } from '../../utils'
8
9
  import { LifecycleRule, S3BucketProps } from './types'
@@ -32,7 +33,7 @@ export class S3Manager {
32
33
  if (!props.lifecycleRules) return undefined
33
34
 
34
35
  const bucketLifecycleRules: LifecycleRule[] = []
35
- props.lifecycleRules.forEach(lifecycleRule => {
36
+ _.forEach(props.lifecycleRules, lifecycleRule => {
36
37
  bucketLifecycleRules.push({
37
38
  abortIncompleteMultipartUploadAfter: lifecycleRule.abortIncompleteMultipartUploadAfter,
38
39
  enabled: lifecycleRule.enabled,
@@ -135,8 +136,8 @@ export class S3Manager {
135
136
  }
136
137
  }
137
138
 
138
- if (props.tags && props.tags.length > 0) {
139
- props.tags.forEach(tag => {
139
+ if (props.tags && !_.isEmpty(props.tags)) {
140
+ _.forEach(props.tags, tag => {
140
141
  Tags.of(bucket).add(tag.key, tag.value)
141
142
  })
142
143
  }
@@ -222,7 +223,7 @@ export class S3Manager {
222
223
  throw `Folder unspecified for ${id}`
223
224
  }
224
225
 
225
- folders.forEach(folder => {
226
+ _.forEach(folders, folder => {
226
227
  new BucketDeployment(scope, `${id}-${folder}`, {
227
228
  destinationBucket: bucket,
228
229
  destinationKeyPrefix: folder,
@@ -30,6 +30,7 @@ import {
30
30
  SqsSendMessage,
31
31
  StepFunctionsStartExecution,
32
32
  } from 'aws-cdk-lib/aws-stepfunctions-tasks'
33
+ import _ from 'lodash'
33
34
  import { v4 as uuidv4 } from 'uuid'
34
35
  import { CommonConstruct } from '../../common'
35
36
  import { createCfnOutput } from '../../utils'
@@ -214,12 +215,12 @@ export class SfnManager {
214
215
  retries = DEFAULT_RETRY_CONFIG
215
216
  }
216
217
 
217
- retries.forEach(retry =>
218
+ _.forEach(retries, retry => {
218
219
  step.addRetry({
219
220
  ...retry,
220
221
  ...{ interval: retry.intervalInSecs ? Duration.seconds(retry.intervalInSecs) : retry.interval },
221
222
  })
222
- )
223
+ })
223
224
 
224
225
  return step
225
226
  }
@@ -267,12 +268,12 @@ export class SfnManager {
267
268
  retries = DEFAULT_RETRY_CONFIG
268
269
  }
269
270
 
270
- retries.forEach(retry =>
271
+ _.forEach(retries, retry => {
271
272
  step.addRetry({
272
273
  ...retry,
273
274
  ...{ interval: retry.intervalInSecs ? Duration.seconds(retry.intervalInSecs) : retry.interval },
274
275
  })
275
- )
276
+ })
276
277
 
277
278
  return step
278
279
  }
@@ -320,12 +321,12 @@ export class SfnManager {
320
321
  retries = DEFAULT_RETRY_CONFIG
321
322
  }
322
323
 
323
- retries.forEach(retry =>
324
+ _.forEach(retries, retry => {
324
325
  step.addRetry({
325
326
  ...retry,
326
327
  ...{ interval: retry.intervalInSecs ? Duration.seconds(retry.intervalInSecs) : retry.interval },
327
328
  })
328
- )
329
+ })
329
330
 
330
331
  return step
331
332
  }
@@ -364,12 +365,12 @@ export class SfnManager {
364
365
  retries = DEFAULT_RETRY_CONFIG
365
366
  }
366
367
 
367
- retries.forEach(retry =>
368
+ _.forEach(retries, retry => {
368
369
  step.addRetry({
369
370
  ...retry,
370
371
  ...{ interval: retry.intervalInSecs ? Duration.seconds(retry.intervalInSecs) : retry.interval },
371
372
  })
372
- )
373
+ })
373
374
 
374
375
  return step
375
376
  }
@@ -396,12 +397,12 @@ export class SfnManager {
396
397
  retries = DEFAULT_RETRY_CONFIG
397
398
  }
398
399
 
399
- retries.forEach(retry =>
400
+ _.forEach(retries, retry => {
400
401
  step.addRetry({
401
402
  ...retry,
402
403
  ...{ interval: retry.intervalInSecs ? Duration.seconds(retry.intervalInSecs) : retry.interval },
403
404
  })
404
- )
405
+ })
405
406
 
406
407
  return step
407
408
  }
@@ -436,12 +437,12 @@ export class SfnManager {
436
437
  retries = DEFAULT_RETRY_CONFIG
437
438
  }
438
439
 
439
- retries.forEach(retry =>
440
+ _.forEach(retries, retry => {
440
441
  step.addRetry({
441
442
  ...retry,
442
443
  ...{ interval: retry.intervalInSecs ? Duration.seconds(retry.intervalInSecs) : retry.interval },
443
444
  })
444
- )
445
+ })
445
446
 
446
447
  return step
447
448
  }
@@ -474,12 +475,12 @@ export class SfnManager {
474
475
  retries = DEFAULT_RETRY_CONFIG
475
476
  }
476
477
 
477
- retries.forEach(retry =>
478
+ _.forEach(retries, retry => {
478
479
  step.addRetry({
479
480
  ...retry,
480
481
  ...{ interval: retry.intervalInSecs ? Duration.seconds(retry.intervalInSecs) : retry.interval },
481
482
  })
482
- )
483
+ })
483
484
 
484
485
  return step
485
486
  }
@@ -510,12 +511,12 @@ export class SfnManager {
510
511
  retries = DEFAULT_RETRY_CONFIG
511
512
  }
512
513
 
513
- retries.forEach(retry =>
514
+ _.forEach(retries, retry => {
514
515
  step.addRetry({
515
516
  ...retry,
516
517
  ...{ interval: retry.intervalInSecs ? Duration.seconds(retry.intervalInSecs) : retry.interval },
517
518
  })
518
- )
519
+ })
519
520
 
520
521
  return step
521
522
  }
@@ -2,6 +2,7 @@ import { Tags } from 'aws-cdk-lib'
2
2
  import { Vpc, VpcProps } from 'aws-cdk-lib/aws-ec2'
3
3
  import { CommonConstruct } from '../../common'
4
4
  import { createCfnOutput } from '../../utils'
5
+ import _ from 'lodash'
5
6
 
6
7
  /**
7
8
  */
@@ -38,17 +39,17 @@ export class VpcManager {
38
39
  })
39
40
 
40
41
  createCfnOutput(`${id}Id`, scope, vpc.vpcId)
41
- createCfnOutput(`${id}PublicSubnetIds`, scope, vpc.publicSubnets.map(subnet => subnet.subnetId).toString())
42
- createCfnOutput(`${id}PrivateSubnetIds`, scope, vpc.privateSubnets.map(subnet => subnet.subnetId).toString())
42
+ createCfnOutput(`${id}PublicSubnetIds`, scope, _.map(vpc.publicSubnets, subnet => subnet.subnetId).toString())
43
+ createCfnOutput(`${id}PrivateSubnetIds`, scope, _.map(vpc.privateSubnets, subnet => subnet.subnetId).toString())
43
44
  createCfnOutput(
44
45
  `${id}PublicSubnetRouteTableIds`,
45
46
  scope,
46
- vpc.publicSubnets.map(subnet => subnet.routeTable.routeTableId).toString()
47
+ _.map(vpc.publicSubnets, subnet => subnet.routeTable.routeTableId).toString()
47
48
  )
48
49
  createCfnOutput(
49
50
  `${id}PrivateSubnetRouteTableIds`,
50
51
  scope,
51
- vpc.privateSubnets.map(subnet => subnet.routeTable.routeTableId).toString()
52
+ _.map(vpc.privateSubnets, subnet => subnet.routeTable.routeTableId).toString()
52
53
  )
53
54
  createCfnOutput(`${id}AvailabilityZones`, scope, vpc.availabilityZones.toString())
54
55
  createCfnOutput(`${id}DefaultSecurityGroup`, scope, vpc.vpcDefaultSecurityGroup.toString())
@@ -3,9 +3,10 @@ import { CommonAzureConstruct } from './construct'
3
3
  import { CommonAzureStackProps } from './types'
4
4
 
5
5
  import appRoot from 'app-root-path'
6
- import { App, TerraformStack } from 'cdktf'
7
- import { isDevStage } from '../../common'
6
+ import { TerraformStack } from 'cdktf'
8
7
  import { Construct } from 'constructs'
8
+ import _ from 'lodash'
9
+ import { isDevStage } from '../../common'
9
10
 
10
11
  /**
11
12
  * @classdesc Common stack to use as a base for all higher level constructs.
@@ -70,7 +71,7 @@ export class CommonAzureStack extends TerraformStack {
70
71
  return
71
72
  }
72
73
 
73
- extraContexts.forEach((context: string) => {
74
+ _.forEach(extraContexts, (context: string) => {
74
75
  const extraContextPath = `${appRoot.path}/${context}`
75
76
 
76
77
  /* scenario where extra context is configured in cdk.json but absent in file system */
@@ -84,7 +85,7 @@ export class CommonAzureStack extends TerraformStack {
84
85
  const extraContextProps = JSON.parse(extraContextPropsBuffer.toString('utf-8'))
85
86
 
86
87
  /* set each of the property into the cdk node context */
87
- Object.keys(extraContextProps).forEach((propKey: any) => {
88
+ _.keys(extraContextProps).forEach((propKey: any) => {
88
89
  this.node.setContext(propKey, extraContextProps[propKey])
89
90
  })
90
91
  })
@@ -120,13 +121,10 @@ export class CommonAzureStack extends TerraformStack {
120
121
  const stageContextProps = JSON.parse(stageContextPropsBuffer.toString('utf-8'))
121
122
 
122
123
  /* set each of the property into the cdk node context */
123
- Object.keys(stageContextProps).forEach((propKey: any) => {
124
+ _.keys(stageContextProps).forEach((propKey: any) => {
124
125
  /* handle object, array properties */
125
126
  if (typeof stageContextProps[propKey] === 'object' && !Array.isArray(stageContextProps[propKey])) {
126
- this.node.setContext(propKey, {
127
- ...this.node.tryGetContext(propKey),
128
- ...stageContextProps[propKey],
129
- })
127
+ this.node.setContext(propKey, _.merge(this.node.tryGetContext(propKey), stageContextProps[propKey]))
130
128
  } else {
131
129
  /* handle all other primitive properties */
132
130
  this.node.setContext(propKey, stageContextProps[propKey])
@@ -1,15 +1,17 @@
1
+ import _ from 'lodash'
2
+
1
3
  export * from './construct'
2
4
  export * from './stack'
3
5
  export * from './types'
4
6
  export * from './utils'
5
7
 
6
8
  export const applyMixins = (derivedCtor: any, constructors: any[]) => {
7
- constructors.forEach(baseCtor => {
8
- Object.getOwnPropertyNames(baseCtor.prototype).forEach(name => {
9
+ _.forEach(constructors, baseConstructor => {
10
+ Object.getOwnPropertyNames(baseConstructor.prototype).forEach(name => {
9
11
  Object.defineProperty(
10
12
  derivedCtor.prototype,
11
13
  name,
12
- Object.getOwnPropertyDescriptor(baseCtor.prototype, name) || Object.create(null)
14
+ Object.getOwnPropertyDescriptor(baseConstructor.prototype, name) || Object.create(null)
13
15
  )
14
16
  })
15
17
  })