@gradientedge/cdk-utils 4.5.2 → 4.6.2

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 (101) hide show
  1. package/app/api-destined-function/package.json +1 -2
  2. package/dist/src/lib/construct/api-to-eventbridge-target/main.d.ts +0 -4
  3. package/dist/src/lib/construct/api-to-eventbridge-target/main.d.ts.map +1 -1
  4. package/dist/src/lib/construct/api-to-eventbridge-target/main.js +24 -12
  5. package/dist/src/lib/construct/api-to-eventbridge-target/main.js.map +1 -1
  6. package/dist/src/lib/construct/graphql-api-lambda-with-cache/index.d.ts +2 -0
  7. package/dist/src/lib/construct/graphql-api-lambda-with-cache/index.d.ts.map +1 -0
  8. package/dist/src/lib/construct/graphql-api-lambda-with-cache/index.js +14 -0
  9. package/dist/src/lib/construct/graphql-api-lambda-with-cache/index.js.map +1 -0
  10. package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.d.ts +65 -0
  11. package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.d.ts.map +1 -0
  12. package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.js +133 -0
  13. package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.js.map +1 -0
  14. package/dist/src/lib/construct/index.d.ts +1 -0
  15. package/dist/src/lib/construct/index.d.ts.map +1 -1
  16. package/dist/src/lib/construct/index.js +1 -0
  17. package/dist/src/lib/construct/index.js.map +1 -1
  18. package/dist/src/lib/manager/aws/vpc-manager.d.ts.map +1 -1
  19. package/dist/src/lib/manager/aws/vpc-manager.js +1 -0
  20. package/dist/src/lib/manager/aws/vpc-manager.js.map +1 -1
  21. package/dist/src/lib/types/aws/index.d.ts +14 -0
  22. package/dist/src/lib/types/aws/index.d.ts.map +1 -1
  23. package/package.json +12 -12
  24. package/src/lib/construct/api-to-eventbridge-target/main.ts +19 -23
  25. package/src/lib/construct/graphql-api-lambda-with-cache/index.ts +1 -0
  26. package/src/lib/construct/graphql-api-lambda-with-cache/main.ts +150 -0
  27. package/src/lib/construct/index.ts +1 -0
  28. package/src/lib/manager/aws/vpc-manager.ts +1 -0
  29. package/src/lib/types/aws/index.ts +15 -0
  30. package/dist/app/api-destined-function/layers/nodejs/node_modules/.bin/uuid +0 -2
  31. package/dist/app/api-destined-function/layers/nodejs/node_modules/.yarn-integrity +0 -109
  32. package/dist/app/api-destined-function/layers/nodejs/node_modules/@types/uuid/LICENSE +0 -21
  33. package/dist/app/api-destined-function/layers/nodejs/node_modules/@types/uuid/README.md +0 -16
  34. package/dist/app/api-destined-function/layers/nodejs/node_modules/@types/uuid/index.d.mts +0 -10
  35. package/dist/app/api-destined-function/layers/nodejs/node_modules/@types/uuid/index.d.ts +0 -80
  36. package/dist/app/api-destined-function/layers/nodejs/node_modules/@types/uuid/package.json +0 -54
  37. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/LICENSE.md +0 -9
  38. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/README.md +0 -505
  39. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/bin/uuid +0 -2
  40. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-browser/index.js +0 -9
  41. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-browser/md5.js +0 -215
  42. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-browser/nil.js +0 -1
  43. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-browser/parse.js +0 -35
  44. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-browser/regex.js +0 -1
  45. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-browser/rng.js +0 -19
  46. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-browser/sha1.js +0 -96
  47. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-browser/stringify.js +0 -30
  48. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-browser/v1.js +0 -95
  49. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-browser/v3.js +0 -4
  50. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-browser/v35.js +0 -64
  51. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-browser/v4.js +0 -24
  52. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-browser/v5.js +0 -4
  53. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-browser/validate.js +0 -7
  54. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-browser/version.js +0 -11
  55. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-node/index.js +0 -9
  56. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-node/md5.js +0 -13
  57. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-node/nil.js +0 -1
  58. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-node/parse.js +0 -35
  59. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-node/regex.js +0 -1
  60. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-node/rng.js +0 -12
  61. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-node/sha1.js +0 -13
  62. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-node/stringify.js +0 -29
  63. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-node/v1.js +0 -95
  64. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-node/v3.js +0 -4
  65. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-node/v35.js +0 -64
  66. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-node/v4.js +0 -24
  67. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-node/v5.js +0 -4
  68. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-node/validate.js +0 -7
  69. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/esm-node/version.js +0 -11
  70. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/index.js +0 -79
  71. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/md5-browser.js +0 -223
  72. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/md5.js +0 -23
  73. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/nil.js +0 -8
  74. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/parse.js +0 -45
  75. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/regex.js +0 -8
  76. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/rng-browser.js +0 -26
  77. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/rng.js +0 -24
  78. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/sha1-browser.js +0 -104
  79. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/sha1.js +0 -23
  80. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/stringify.js +0 -39
  81. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/umd/uuid.min.js +0 -1
  82. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/umd/uuidNIL.min.js +0 -1
  83. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/umd/uuidParse.min.js +0 -1
  84. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/umd/uuidStringify.min.js +0 -1
  85. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/umd/uuidValidate.min.js +0 -1
  86. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/umd/uuidVersion.min.js +0 -1
  87. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/umd/uuidv1.min.js +0 -1
  88. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/umd/uuidv3.min.js +0 -1
  89. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/umd/uuidv4.min.js +0 -1
  90. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/umd/uuidv5.min.js +0 -1
  91. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/uuid-bin.js +0 -85
  92. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/v1.js +0 -107
  93. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/v3.js +0 -16
  94. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/v35.js +0 -78
  95. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/v4.js +0 -37
  96. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/v5.js +0 -16
  97. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/validate.js +0 -17
  98. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/dist/version.js +0 -21
  99. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/package.json +0 -135
  100. package/dist/app/api-destined-function/layers/nodejs/node_modules/uuid/wrapper.mjs +0 -10
  101. package/dist/app/api-destined-function/layers/nodejs/package.json +0 -30
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "4.5.2",
3
+ "version": "4.6.2",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -43,13 +43,13 @@
43
43
  }
44
44
  },
45
45
  "dependencies": {
46
- "@aws-cdk/aws-lambda-python-alpha": "2.10.0-alpha.0",
46
+ "@aws-cdk/aws-lambda-python-alpha": "2.12.0-alpha.0",
47
47
  "@types/lodash": "^4.14.178",
48
- "@types/node": "^17.0.16",
48
+ "@types/node": "^17.0.18",
49
49
  "app-root-path": "^3.0.0",
50
- "aws-cdk-lib": "^2.10.0",
51
- "aws-sdk": "^2.1070.0",
52
- "constructs": "^10.0.55",
50
+ "aws-cdk-lib": "^2.12.0",
51
+ "aws-sdk": "^2.1074.0",
52
+ "constructs": "^10.0.62",
53
53
  "lodash": "^4.17.21",
54
54
  "moment": "^2.29.1",
55
55
  "nconf": "^0.11.3",
@@ -59,19 +59,19 @@
59
59
  "devDependencies": {
60
60
  "@babel/plugin-proposal-class-properties": "^7.16.7",
61
61
  "@types/jest": "^27.4.0",
62
- "@typescript-eslint/eslint-plugin": "^5.11.0",
63
- "@typescript-eslint/parser": "^5.11.0",
62
+ "@typescript-eslint/eslint-plugin": "^5.12.0",
63
+ "@typescript-eslint/parser": "^5.12.0",
64
64
  "aws-cdk": "*",
65
65
  "babel-eslint": "^10.1.0",
66
- "better-docs": "^2.7.1",
66
+ "better-docs": "^2.7.2",
67
67
  "codecov": "^3.8.3",
68
68
  "commitizen": "^4.2.4",
69
69
  "dotenv": "^16.0.0",
70
- "eslint": "^8.8.0",
70
+ "eslint": "^8.9.0",
71
71
  "eslint-config-prettier": "^8.3.0",
72
72
  "eslint-plugin-import": "^2.25.4",
73
73
  "husky": "^7.0.4",
74
- "jest": "^27.5.0",
74
+ "jest": "^27.5.1",
75
75
  "jest-extended": "^2.0.0",
76
76
  "jest-junit": "^13.0.0",
77
77
  "jsdoc": "^3.6.10",
@@ -87,7 +87,7 @@
87
87
  "typescript": "4.5.5"
88
88
  },
89
89
  "optionalDependencies": {
90
- "@babel/core": "^7.17.0",
90
+ "@babel/core": "^7.17.2",
91
91
  "prop-types": "^15.8.1",
92
92
  "react": "^17.0.2",
93
93
  "react-dom": "^17.0.2"
@@ -41,7 +41,6 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
41
41
  applicationSecrets: secretsmanager.ISecret[]
42
42
 
43
43
  /* destined lambda related resources */
44
- apiDestinedLambdaDirectory = 'app/api-destined-function'
45
44
  apiDestinedLambda: types.ApiDestinedLambdaType
46
45
 
47
46
  /* event related resources */
@@ -190,26 +189,18 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
190
189
  }
191
190
  }
192
191
 
193
- protected createApiDestinedLambdaLayersSource() {
194
- return (
195
- this.props.lambda.layerSource ??
196
- new lambda.AssetCode(`../node_modules/@gradientedge/cdk-utils/dist/${this.apiDestinedLambdaDirectory}/layers`)
197
- )
198
- }
199
-
200
192
  /**
201
193
  * @summary Method to create layers for Api Destined Lambda function
202
194
  * @protected
203
195
  */
204
196
  protected createApiDestinedLambdaLayers() {
205
197
  const layers: lambda.LayerVersion[] = []
206
- layers.push(
207
- this.lambdaManager.createLambdaLayer(
208
- `${this.id}-lambda-destined-layer`,
209
- this,
210
- this.createApiDestinedLambdaLayersSource()
198
+ if (this.props.lambda.layerSource) {
199
+ layers.push(
200
+ this.lambdaManager.createLambdaLayer(`${this.id}-lambda-destined-layer`, this, this.props.lambda.layerSource)
211
201
  )
212
- )
202
+ }
203
+
213
204
  this.apiDestinedLambda.layers = layers
214
205
  }
215
206
 
@@ -222,18 +213,13 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
222
213
  this.apiDestinedLambda.destinationFailure = new destinations.EventBridgeDestination(this.apiEvent.eventBus)
223
214
  }
224
215
 
225
- protected createApiDestinedLambdaFunctionSource() {
226
- return (
227
- this.props.lambda.source ??
228
- new lambda.AssetCode(`../node_modules/@gradientedge/cdk-utils/dist/${this.apiDestinedLambdaDirectory}/src/lib`)
229
- )
230
- }
231
-
232
216
  /**
233
217
  * @summary Method to create lambda function for Api Destined
234
218
  * @protected
235
219
  */
236
220
  protected createApiDestinedLambdaFunction() {
221
+ if (!this.props.lambda.source) throw 'Api Destined Lambda props undefined'
222
+
237
223
  this.apiDestinedLambda.function = this.lambdaManager.createLambdaFunction(
238
224
  `${this.id}-lambda-destined`,
239
225
  this,
@@ -246,8 +232,8 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
246
232
  },
247
233
  this.apiDestinedLambda.role,
248
234
  this.apiDestinedLambda.layers,
249
- this.createApiDestinedLambdaFunctionSource(),
250
- 'lambda.handler',
235
+ this.props.lambda.source,
236
+ this.props.lambda.handler ?? 'lambda.handler',
251
237
  this.apiDestinedLambda.environment
252
238
  )
253
239
  }
@@ -420,18 +406,22 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
420
406
  }
421
407
 
422
408
  protected createApiDestinedResource() {
409
+ if (!this.props.api.withResource) return
410
+
423
411
  this.apiDestinedRestApi.resource = this.apiDestinedRestApi.api.root.addResource(
424
412
  this.props.api.resource ?? this.apiResource
425
413
  )
426
414
  }
427
415
 
428
416
  protected createApiDestinedIntegrationRequestParameters() {
417
+ if (!this.props.api.withResource) return
429
418
  this.apiDestinedRestApi.integrationRequestParameters = {
430
419
  'integration.request.header.Content-Type': "'application/x-www-form-urlencoded'",
431
420
  }
432
421
  }
433
422
 
434
423
  protected createApiDestinedIntegrationRequestTemplates() {
424
+ if (!this.props.api.withResource) return
435
425
  this.apiDestinedRestApi.integrationRequestTemplates = {
436
426
  'application/json': [
437
427
  'Action=Publish',
@@ -443,6 +433,7 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
443
433
  }
444
434
 
445
435
  protected createApiDestinedIntegrationResponse() {
436
+ if (!this.props.api.withResource) return
446
437
  this.apiDestinedRestApi.integrationResponse = {
447
438
  ...{
448
439
  statusCode: '200',
@@ -455,6 +446,7 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
455
446
  }
456
447
 
457
448
  protected createApiDestinedIntegrationErrorResponse() {
449
+ if (!this.props.api.withResource) return
458
450
  this.apiDestinedRestApi.integrationErrorResponse = {
459
451
  ...{
460
452
  selectionPattern: '^\\[Error\\].*',
@@ -476,6 +468,7 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
476
468
  }
477
469
 
478
470
  protected createApiDestinedIntegration() {
471
+ if (!this.props.api.withResource) return
479
472
  this.apiDestinedRestApi.integration = new apig.Integration({
480
473
  type: apig.IntegrationType.AWS,
481
474
  integrationHttpMethod: 'POST',
@@ -497,6 +490,7 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
497
490
  }
498
491
 
499
492
  protected createApiDestinedMethodResponse() {
493
+ if (!this.props.api.withResource) return
500
494
  this.apiDestinedRestApi.methodResponse = {
501
495
  ...{
502
496
  statusCode: '200',
@@ -514,6 +508,7 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
514
508
  }
515
509
 
516
510
  protected createApiDestinedMethodErrorResponse() {
511
+ if (!this.props.api.withResource) return
517
512
  this.apiDestinedRestApi.methodErrorResponse = {
518
513
  ...{
519
514
  statusCode: '400',
@@ -531,6 +526,7 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
531
526
  }
532
527
 
533
528
  protected createApiDestinedResourceMethod() {
529
+ if (!this.props.api.withResource) return
534
530
  this.apiDestinedRestApi.method = this.apiDestinedRestApi.resource.addMethod(
535
531
  'POST',
536
532
  this.apiDestinedRestApi.integration,
@@ -0,0 +1 @@
1
+ export * from './main'
@@ -0,0 +1,150 @@
1
+ import * as cdk from 'aws-cdk-lib'
2
+ import * as ec2 from 'aws-cdk-lib/aws-ec2'
3
+ import * as elasticache from 'aws-cdk-lib/aws-elasticache'
4
+ import * as iam from 'aws-cdk-lib/aws-iam'
5
+ import { Construct } from 'constructs'
6
+ import { GraphQLApiLambda } from '..'
7
+ import { GraphQlApiLambdaWithCacheProps } from '../../types'
8
+ import * as utils from '../../utils'
9
+
10
+ /**
11
+ * @stability stable
12
+ * @category cdk-utils.graphql-api-lambda-with-cache
13
+ * @subcategory construct
14
+ * @classdesc Provides a construct to create and deploy a Graphql API as Lambda with Caching
15
+ *
16
+ * <b>Architecture</b> ![Architecture](./GraphQLApiLambda.jpg)
17
+ *
18
+ * @example
19
+ * import { GraphQlApiLambdaWithCacheProps } '@gradientedge/cdk-utils'
20
+ * import { Construct } from 'constructs'
21
+ *
22
+ * class CustomConstruct extends GraphQLApiLambdaWithCache {
23
+ * constructor(parent: Construct, id: string, props: GraphQlApiLambdaWithCacheProps) {
24
+ * super(parent, id, props)
25
+ * this.props = props
26
+ * this.id = id
27
+ * this.initResources()
28
+ * }
29
+ * }
30
+ */
31
+ export class GraphQLApiLambdaWithCache extends GraphQLApiLambda {
32
+ /* graphql restApi props */
33
+ props: GraphQlApiLambdaWithCacheProps
34
+ id: string
35
+
36
+ /* graphql restApi resources */
37
+ graphQLVpc: ec2.IVpc
38
+ graphQLElastiCache: elasticache.CfnCacheCluster
39
+ graphQLSecurityGroup: ec2.ISecurityGroup
40
+ securityGroupStackName: string
41
+ securityGroupExportName: string
42
+ vpcExportName: string
43
+
44
+ constructor(parent: Construct, id: string, props: GraphQlApiLambdaWithCacheProps) {
45
+ super(parent, id, props)
46
+
47
+ this.props = props
48
+ this.id = id
49
+ }
50
+
51
+ protected initResources() {
52
+ this.setVpc()
53
+ this.setSecurityGroup()
54
+ this.createElastiCache()
55
+ super.initResources()
56
+ }
57
+
58
+ /**
59
+ * Create VPC
60
+ * @protected
61
+ */
62
+ protected setVpc() {
63
+ if (this.props.vpcExportName) {
64
+ this.graphQLVpc = this.vpcManager.retrieveCommonVpc(`${this.id}`, this, this.props.vpcExportName)
65
+ } else {
66
+ this.graphQLVpc = this.vpcManager.createCommonVpc(this, this.props.graphQLVpc, this.props.graphQLVpc.vpcName)
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Resolve Security Group
72
+ * @protected
73
+ */
74
+ protected setSecurityGroup() {
75
+ if (this.props.securityGroupExportName) {
76
+ this.graphQLSecurityGroup = ec2.SecurityGroup.fromSecurityGroupId(
77
+ this,
78
+ `${this.id}`,
79
+ cdk.Fn.importValue(this.props.securityGroupExportName)
80
+ )
81
+ } else {
82
+ this.graphQLSecurityGroup = new ec2.SecurityGroup(this, `${this.id}-security-group-${this.props.stage}`, {
83
+ securityGroupName: `${this.id}-security-group-${this.props.stage}`,
84
+ vpc: this.graphQLVpc,
85
+ })
86
+
87
+ this.graphQLSecurityGroup.addIngressRule(ec2.Peer.anyIpv4(), ec2.Port.allIcmp(), 'All Traffic')
88
+
89
+ utils.createCfnOutput(`${this.id}-security-group-id`, this, this.graphQLSecurityGroup.securityGroupId)
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Create ElastiCache
95
+ * @protected
96
+ */
97
+ protected createElastiCache() {
98
+ this.graphQLElastiCache = this.elasticacheManager.createElastiCache(
99
+ `${this.id}-elasticache`,
100
+ this,
101
+ this.props.graphQLElastiCache,
102
+ this.graphQLVpc.privateSubnets.map(subnet => subnet.subnetId),
103
+ [this.graphQLSecurityGroup.toString()]
104
+ )
105
+ }
106
+
107
+ /**
108
+ * Create Lambda Role
109
+ * @protected
110
+ */
111
+ protected createLambdaRole() {
112
+ super.createLambdaRole()
113
+
114
+ this.graphQLApiLambdaRole.addManagedPolicy(
115
+ iam.ManagedPolicy.fromAwsManagedPolicyName('service-role/AWSLambdaVPCAccessExecutionRole')
116
+ )
117
+ }
118
+
119
+ /**
120
+ * @summary Method to create environment variables for GraphQL Lambda function
121
+ * @protected
122
+ */
123
+ protected createLambdaEnvironment() {
124
+ this.graphQLApiLambdaEnvironment = {
125
+ CACHE_REDIS_HOST: `${this.graphQLElastiCache.attrRedisEndpointAddress}`,
126
+ CACHE_REDIS_PORT: `${this.graphQLElastiCache.attrRedisEndpointPort}`,
127
+ NODE_ENV: this.props.nodeEnv,
128
+ LOG_LEVEL: this.props.logLevel,
129
+ TZ: this.props.timezone,
130
+ }
131
+ }
132
+
133
+ protected createLambdaFunction() {
134
+ this.graphQLApiLambdaFunction = this.lambdaManager.createLambdaFunction(
135
+ `${this.id}-graphql-server`,
136
+ this,
137
+ this.props.graphqlApi,
138
+ this.graphQLApiLambdaRole,
139
+ this.graphQLApiLambdaLayers,
140
+ this.props.graphQLApiSource,
141
+ this.props.graphQLApiHandler || 'index.handler',
142
+ this.graphQLApiLambdaEnvironment,
143
+ this.graphQLVpc,
144
+ [this.graphQLSecurityGroup],
145
+ undefined,
146
+ undefined,
147
+ this.graphQLVpc
148
+ )
149
+ }
150
+ }
@@ -1,4 +1,5 @@
1
1
  export * from './api-to-eventbridge-target'
2
2
  export * from './graphql-api-lambda'
3
+ export * from './graphql-api-lambda-with-cache'
3
4
  export * from './site-with-ecs-backend'
4
5
  export * from './static-site'
@@ -57,6 +57,7 @@ export class VpcManager {
57
57
  vpc.privateSubnets.map(subnet => subnet.routeTable.routeTableId).toString()
58
58
  )
59
59
  utils.createCfnOutput(`${id}AvailabilityZones`, scope, vpc.availabilityZones.toString())
60
+ utils.createCfnOutput(`${id}DefaultSecurityGroup`, scope, vpc.vpcDefaultSecurityGroup.toString())
60
61
 
61
62
  return vpc
62
63
  }
@@ -113,6 +113,8 @@ export interface HealthCheck extends elb.HealthCheck {
113
113
  * @subcategory Types
114
114
  */
115
115
  export interface LambdaEnvironment {
116
+ CACHE_REDIS_HOST?: string
117
+ CACHE_REDIS_PORT?: string
116
118
  NODE_ENV: string
117
119
  LOG_LEVEL: string
118
120
  TZ: string
@@ -151,6 +153,17 @@ export interface GraphQlApiLambdaProps extends CommonStackProps {
151
153
  timezone: string
152
154
  }
153
155
 
156
+ /**
157
+ * @category cdk-utils.graphql-api-lambda-with-cache
158
+ * @subcategory Properties
159
+ */
160
+ export interface GraphQlApiLambdaWithCacheProps extends GraphQlApiLambdaProps {
161
+ graphQLVpc: ec2.VpcProps
162
+ graphQLElastiCache: ElastiCacheProps
163
+ securityGroupExportName: string
164
+ vpcExportName: string
165
+ }
166
+
154
167
  /**
155
168
  * @category cdk-utils.api-to-eventbridge-target
156
169
  * @subcategory Types
@@ -208,6 +221,7 @@ export interface ApiDestinedLambdaType {
208
221
  * @subcategory Properties
209
222
  */
210
223
  export interface ApiToEventBridgeTargetRestApiProps {
224
+ withResource?: boolean
211
225
  certificate: AcmProps
212
226
  integrationResponse?: apig.IntegrationResponse
213
227
  integrationErrorResponse?: apig.IntegrationResponse
@@ -225,6 +239,7 @@ export interface ApiToEventBridgeTargetRestApiProps {
225
239
  * @subcategory Properties
226
240
  */
227
241
  interface ApiToEventBridgeTargetLambdaProps {
242
+ handler?: string
228
243
  function: LambdaProps
229
244
  source?: lambda.AssetCode
230
245
  layerSource?: lambda.AssetCode
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- require('../uuid-bin');
@@ -1,109 +0,0 @@
1
- {
2
- "systemParams": "linux-x64-83",
3
- "modulesFolders": [
4
- "node_modules"
5
- ],
6
- "flags": [
7
- "checkFiles",
8
- "production"
9
- ],
10
- "linkedModules": [],
11
- "topLevelPatterns": [
12
- "@types/uuid@^8.3.4",
13
- "mkdirp@^1.0.4",
14
- "rimraf@^3.0.2",
15
- "uuid@^8.3.2"
16
- ],
17
- "lockfileEntries": {
18
- "@types/uuid@^8.3.4": "https://registry.yarnpkg.com/@types/uuid/-/uuid-8.3.4.tgz#bd86a43617df0594787d38b735f55c805becf1bc",
19
- "balanced-match@^1.0.0": "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee",
20
- "brace-expansion@^1.1.7": "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd",
21
- "concat-map@0.0.1": "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b",
22
- "fs.realpath@^1.0.0": "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f",
23
- "glob@^7.1.3": "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023",
24
- "inflight@^1.0.4": "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9",
25
- "inherits@2": "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c",
26
- "minimatch@^3.0.4": "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.5.tgz#4da8f1290ee0f0f8e83d60ca69f8f134068604a3",
27
- "mkdirp@^1.0.4": "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e",
28
- "once@^1.3.0": "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1",
29
- "path-is-absolute@^1.0.0": "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f",
30
- "rimraf@^3.0.2": "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a",
31
- "uuid@^8.3.2": "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2",
32
- "wrappy@1": "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
33
- },
34
- "files": [
35
- ".bin/uuid",
36
- "@types/uuid/LICENSE",
37
- "@types/uuid/README.md",
38
- "@types/uuid/index.d.mts",
39
- "@types/uuid/index.d.ts",
40
- "@types/uuid/package.json",
41
- "uuid/CHANGELOG.md",
42
- "uuid/CONTRIBUTING.md",
43
- "uuid/LICENSE.md",
44
- "uuid/README.md",
45
- "uuid/dist/bin/uuid",
46
- "uuid/dist/esm-browser/index.js",
47
- "uuid/dist/esm-browser/md5.js",
48
- "uuid/dist/esm-browser/nil.js",
49
- "uuid/dist/esm-browser/parse.js",
50
- "uuid/dist/esm-browser/regex.js",
51
- "uuid/dist/esm-browser/rng.js",
52
- "uuid/dist/esm-browser/sha1.js",
53
- "uuid/dist/esm-browser/stringify.js",
54
- "uuid/dist/esm-browser/v1.js",
55
- "uuid/dist/esm-browser/v3.js",
56
- "uuid/dist/esm-browser/v35.js",
57
- "uuid/dist/esm-browser/v4.js",
58
- "uuid/dist/esm-browser/v5.js",
59
- "uuid/dist/esm-browser/validate.js",
60
- "uuid/dist/esm-browser/version.js",
61
- "uuid/dist/esm-node/index.js",
62
- "uuid/dist/esm-node/md5.js",
63
- "uuid/dist/esm-node/nil.js",
64
- "uuid/dist/esm-node/parse.js",
65
- "uuid/dist/esm-node/regex.js",
66
- "uuid/dist/esm-node/rng.js",
67
- "uuid/dist/esm-node/sha1.js",
68
- "uuid/dist/esm-node/stringify.js",
69
- "uuid/dist/esm-node/v1.js",
70
- "uuid/dist/esm-node/v3.js",
71
- "uuid/dist/esm-node/v35.js",
72
- "uuid/dist/esm-node/v4.js",
73
- "uuid/dist/esm-node/v5.js",
74
- "uuid/dist/esm-node/validate.js",
75
- "uuid/dist/esm-node/version.js",
76
- "uuid/dist/index.js",
77
- "uuid/dist/md5-browser.js",
78
- "uuid/dist/md5.js",
79
- "uuid/dist/nil.js",
80
- "uuid/dist/parse.js",
81
- "uuid/dist/regex.js",
82
- "uuid/dist/rng-browser.js",
83
- "uuid/dist/rng.js",
84
- "uuid/dist/sha1-browser.js",
85
- "uuid/dist/sha1.js",
86
- "uuid/dist/stringify.js",
87
- "uuid/dist/umd/uuid.min.js",
88
- "uuid/dist/umd/uuidNIL.min.js",
89
- "uuid/dist/umd/uuidParse.min.js",
90
- "uuid/dist/umd/uuidStringify.min.js",
91
- "uuid/dist/umd/uuidValidate.min.js",
92
- "uuid/dist/umd/uuidVersion.min.js",
93
- "uuid/dist/umd/uuidv1.min.js",
94
- "uuid/dist/umd/uuidv3.min.js",
95
- "uuid/dist/umd/uuidv4.min.js",
96
- "uuid/dist/umd/uuidv5.min.js",
97
- "uuid/dist/uuid-bin.js",
98
- "uuid/dist/v1.js",
99
- "uuid/dist/v3.js",
100
- "uuid/dist/v35.js",
101
- "uuid/dist/v4.js",
102
- "uuid/dist/v5.js",
103
- "uuid/dist/validate.js",
104
- "uuid/dist/version.js",
105
- "uuid/package.json",
106
- "uuid/wrapper.mjs"
107
- ],
108
- "artifacts": {}
109
- }
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) Microsoft Corporation.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE
@@ -1,16 +0,0 @@
1
- # Installation
2
- > `npm install --save @types/uuid`
3
-
4
- # Summary
5
- This package contains type definitions for uuid (https://github.com/uuidjs/uuid).
6
-
7
- # Details
8
- Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/uuid.
9
-
10
- ### Additional Details
11
- * Last updated: Thu, 06 Jan 2022 07:31:27 GMT
12
- * Dependencies: none
13
- * Global values: none
14
-
15
- # Credits
16
- These definitions were written by [Oliver Hoffmann](https://github.com/iamolivinius), [Felipe Ochoa](https://github.com/felipeochoa), [Chris Barth](https://github.com/cjbarth), [Linus Unnebäck](https://github.com/LinusU), and [Christoph Tavan](https://github.com/ctavan).
@@ -1,10 +0,0 @@
1
- import uuid from './index.js';
2
- export import v1 = uuid.v1;
3
- export import v3 = uuid.v3;
4
- export import v4 = uuid.v4;
5
- export import v5 = uuid.v5;
6
- export import NIL = uuid.NIL;
7
- export import version = uuid.version;
8
- export import validate = uuid.validate;
9
- export import stringify = uuid.stringify;
10
- export import parse = uuid.parse;
@@ -1,80 +0,0 @@
1
- // Type definitions for uuid 8.3
2
- // Project: https://github.com/uuidjs/uuid
3
- // Definitions by: Oliver Hoffmann <https://github.com/iamolivinius>
4
- // Felipe Ochoa <https://github.com/felipeochoa>
5
- // Chris Barth <https://github.com/cjbarth>
6
- // Linus Unnebäck <https://github.com/LinusU>
7
- // Christoph Tavan <https://github.com/ctavan>
8
- // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
9
- // TypeScript Version: 2.8
10
-
11
- // disable automatic export
12
- export {};
13
-
14
- // Uses ArrayLike to admit Unit8 and co.
15
- type OutputBuffer = ArrayLike<number>;
16
- type InputBuffer = ArrayLike<number>;
17
-
18
- interface RandomOptions {
19
- random?: InputBuffer | undefined;
20
- }
21
- interface RngOptions {
22
- rng?: (() => InputBuffer) | undefined;
23
- }
24
-
25
- interface V1BaseOptions {
26
- node?: InputBuffer | undefined;
27
- clockseq?: number | undefined;
28
- msecs?: number | Date | undefined;
29
- nsecs?: number | undefined;
30
- }
31
- interface V1RandomOptions extends V1BaseOptions, RandomOptions {}
32
- interface V1RngOptions extends V1BaseOptions, RngOptions {}
33
-
34
- export type V1Options = V1RandomOptions | V1RngOptions;
35
- export type V4Options = RandomOptions | RngOptions;
36
-
37
- type v1String = (options?: V1Options) => string;
38
- type v1Buffer = <T extends OutputBuffer>(options: V1Options | null | undefined, buffer: T, offset?: number) => T;
39
- type v1 = v1Buffer & v1String;
40
-
41
- type v4String = (options?: V4Options) => string;
42
- type v4Buffer = <T extends OutputBuffer>(options: V4Options | null | undefined, buffer: T, offset?: number) => T;
43
- type v4 = v4Buffer & v4String;
44
-
45
- type v3String = (name: string | InputBuffer, namespace: string | InputBuffer) => string;
46
- type v3Buffer = <T extends OutputBuffer>(name: string | InputBuffer, namespace: string | InputBuffer, buffer: T, offset?: number) => T;
47
- interface v3Static {
48
- // https://github.com/uuidjs/uuid/blob/master/src/v35.js#L22
49
- DNS: string;
50
- // https://github.com/uuidjs/uuid/blob/master/src/v35.js#L23
51
- URL: string;
52
- }
53
- type v3 = v3Buffer & v3String & v3Static;
54
-
55
- type v5String = (name: string | InputBuffer, namespace: string | InputBuffer) => string;
56
- type v5Buffer = <T extends OutputBuffer>(name: string | InputBuffer, namespace: string | InputBuffer, buffer: T, offset?: number) => T;
57
- interface v5Static {
58
- // https://github.com/uuidjs/uuid/blob/master/src/v35.js#L22
59
- DNS: string;
60
- // https://github.com/uuidjs/uuid/blob/master/src/v35.js#L23
61
- URL: string;
62
- }
63
- type v5 = v5Buffer & v5String & v5Static;
64
-
65
- type NIL = string;
66
-
67
- type parse = (uuid: string) => OutputBuffer;
68
- type stringify = (buffer: InputBuffer, offset?: number) => string;
69
- type validate = (uuid: string) => boolean;
70
- type version = (uuid: string) => number;
71
-
72
- export const NIL: NIL;
73
- export const parse: parse;
74
- export const stringify: stringify;
75
- export const v1: v1;
76
- export const v3: v3;
77
- export const v4: v4;
78
- export const v5: v5;
79
- export const validate: validate;
80
- export const version: version;