@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
@@ -187,12 +187,10 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
187
187
  protected createApiToEventBridgeTargetRule() {
188
188
  if (this.props.api.useExisting) return
189
189
  this.props.event.rule = {
190
- ...{
191
- eventPattern: {
192
- source: ['api-to-eventbridge-target'],
193
- },
194
- ruleName: `${this.id}-api-to-eventbridge-target`,
190
+ eventPattern: {
191
+ source: ['api-to-eventbridge-target'],
195
192
  },
193
+ ruleName: `${this.id}-api-to-eventbridge-target`,
196
194
  ...this.props.event.rule,
197
195
  }
198
196
  this.apiEvent.rule = this.eventManager.createRule(
@@ -261,12 +259,10 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
261
259
  protected createApiToEventBridgeTargetIntegrationResponse() {
262
260
  if (!this.props.api.withResource) return
263
261
  this.apiToEventBridgeTargetRestApi.integrationResponse = this.props.api.integrationResponse ?? {
264
- ...{
265
- responseTemplates: {
266
- 'application/json': JSON.stringify({ message: 'Payload Submitted' }),
267
- },
268
- statusCode: '200',
262
+ responseTemplates: {
263
+ 'application/json': JSON.stringify({ message: 'Payload Submitted' }),
269
264
  },
265
+ statusCode: '200',
270
266
  }
271
267
  }
272
268
 
@@ -276,21 +272,19 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
276
272
  protected createApiToEventBridgeTargetIntegrationErrorResponse() {
277
273
  if (!this.props.api.withResource) return
278
274
  this.apiToEventBridgeTargetRestApi.integrationErrorResponse = {
279
- ...{
280
- responseParameters: {
281
- 'method.response.header.Access-Control-Allow-Credentials': "'true'",
282
- 'method.response.header.Access-Control-Allow-Origin': "'*'",
283
- 'method.response.header.Content-Type': "'application/json'",
284
- },
285
- responseTemplates: {
286
- 'application/json': JSON.stringify({
287
- message: "$util.escapeJavaScript($input.path('$.errorMessage'))",
288
- state: 'error',
289
- }),
290
- },
291
- selectionPattern: '^\\[Error\\].*',
292
- statusCode: '400',
275
+ responseParameters: {
276
+ 'method.response.header.Access-Control-Allow-Credentials': "'true'",
277
+ 'method.response.header.Access-Control-Allow-Origin': "'*'",
278
+ 'method.response.header.Content-Type': "'application/json'",
293
279
  },
280
+ responseTemplates: {
281
+ 'application/json': JSON.stringify({
282
+ message: "$util.escapeJavaScript($input.path('$.errorMessage'))",
283
+ state: 'error',
284
+ }),
285
+ },
286
+ selectionPattern: '^\\[Error\\].*',
287
+ statusCode: '400',
294
288
  ...this.props.api.integrationErrorResponse,
295
289
  }
296
290
  }
@@ -303,16 +297,14 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
303
297
  this.apiToEventBridgeTargetRestApi.integration = new Integration({
304
298
  integrationHttpMethod: 'POST',
305
299
  options: {
306
- ...{
307
- credentialsRole: this.apiToEventBridgeTargetRestApi.role,
308
- integrationResponses: [
309
- this.apiToEventBridgeTargetRestApi.integrationResponse,
310
- this.apiToEventBridgeTargetRestApi.integrationErrorResponse,
311
- ],
312
- passthroughBehavior: PassthroughBehavior.NEVER,
313
- requestParameters: this.apiToEventBridgeTargetRestApi.integrationRequestParameters,
314
- requestTemplates: this.apiToEventBridgeTargetRestApi.integrationRequestTemplates,
315
- },
300
+ credentialsRole: this.apiToEventBridgeTargetRestApi.role,
301
+ integrationResponses: [
302
+ this.apiToEventBridgeTargetRestApi.integrationResponse,
303
+ this.apiToEventBridgeTargetRestApi.integrationErrorResponse,
304
+ ],
305
+ passthroughBehavior: PassthroughBehavior.NEVER,
306
+ requestParameters: this.apiToEventBridgeTargetRestApi.integrationRequestParameters,
307
+ requestTemplates: this.apiToEventBridgeTargetRestApi.integrationRequestTemplates,
316
308
  ...this.props.api.integrationOptions,
317
309
  },
318
310
  type: IntegrationType.AWS,
@@ -326,17 +318,15 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
326
318
  protected createApiToEventBridgeTargetMethodResponse() {
327
319
  if (!this.props.api.withResource) return
328
320
  this.apiToEventBridgeTargetRestApi.methodResponse = {
329
- ...{
330
- responseModels: {
331
- 'application/json': this.apiToEventBridgeTargetRestApi.responseModel,
332
- },
333
- responseParameters: {
334
- 'method.response.header.Access-Control-Allow-Credentials': true,
335
- 'method.response.header.Access-Control-Allow-Origin': true,
336
- 'method.response.header.Content-Type': true,
337
- },
338
- statusCode: '200',
321
+ responseModels: {
322
+ 'application/json': this.apiToEventBridgeTargetRestApi.responseModel,
339
323
  },
324
+ responseParameters: {
325
+ 'method.response.header.Access-Control-Allow-Credentials': true,
326
+ 'method.response.header.Access-Control-Allow-Origin': true,
327
+ 'method.response.header.Content-Type': true,
328
+ },
329
+ statusCode: '200',
340
330
  ...this.props.api.methodResponse,
341
331
  }
342
332
  }
@@ -347,17 +337,15 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
347
337
  protected createApiToEventBridgeTargetMethodErrorResponse() {
348
338
  if (!this.props.api.withResource) return
349
339
  this.apiToEventBridgeTargetRestApi.methodErrorResponse = {
350
- ...{
351
- responseModels: {
352
- 'application/json': this.apiToEventBridgeTargetRestApi.errorResponseModel,
353
- },
354
- responseParameters: {
355
- 'method.response.header.Access-Control-Allow-Credentials': true,
356
- 'method.response.header.Access-Control-Allow-Origin': true,
357
- 'method.response.header.Content-Type': true,
358
- },
359
- statusCode: '400',
340
+ responseModels: {
341
+ 'application/json': this.apiToEventBridgeTargetRestApi.errorResponseModel,
360
342
  },
343
+ responseParameters: {
344
+ 'method.response.header.Access-Control-Allow-Credentials': true,
345
+ 'method.response.header.Access-Control-Allow-Origin': true,
346
+ 'method.response.header.Content-Type': true,
347
+ },
348
+ statusCode: '400',
361
349
  ...this.props.api.methodErrorResponse,
362
350
  }
363
351
  }
@@ -387,36 +375,34 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
387
375
  }
388
376
 
389
377
  this.apiToEventBridgeTargetRestApi.api = new RestApi(this, `${this.id}-rest-api`, {
390
- ...{
391
- cloudWatchRole: this.props.api.restApi?.cloudWatchRole ?? true,
392
- defaultCorsPreflightOptions: {
393
- allowHeaders: Cors.DEFAULT_HEADERS,
394
- allowMethods: ['POST'],
395
- allowOrigins: Cors.ALL_ORIGINS,
396
- },
397
- defaultIntegration: this.apiToEventBridgeTargetRestApi.integration,
398
- defaultMethodOptions: {
399
- methodResponses: [
400
- this.apiToEventBridgeTargetRestApi.methodResponse,
401
- this.apiToEventBridgeTargetRestApi.methodErrorResponse,
402
- ],
403
- },
404
- deploy: this.props.api.restApi?.deploy ?? true,
405
- deployOptions: {
406
- accessLogDestination: new LogGroupLogDestination(this.apiToEventBridgeTargetRestApi.accessLogGroup),
407
- accessLogFormat: AccessLogFormat.jsonWithStandardFields(),
408
- dataTraceEnabled: this.props.api.restApi?.deployOptions?.dataTraceEnabled,
409
- description: `${this.id} - ${this.props.stage} stage`,
410
- loggingLevel: MethodLoggingLevel.INFO,
411
- metricsEnabled: true,
412
- stageName: this.props.stage,
413
- tracingEnabled: this.props.api.restApi?.deployOptions?.tracingEnabled,
414
- },
415
- endpointConfiguration: {
416
- types: [EndpointType.REGIONAL],
417
- },
418
- restApiName: `${this.id}-rest-api-${this.props.stage}`,
378
+ cloudWatchRole: this.props.api.restApi?.cloudWatchRole ?? true,
379
+ defaultCorsPreflightOptions: {
380
+ allowHeaders: Cors.DEFAULT_HEADERS,
381
+ allowMethods: ['POST'],
382
+ allowOrigins: Cors.ALL_ORIGINS,
383
+ },
384
+ defaultIntegration: this.apiToEventBridgeTargetRestApi.integration,
385
+ defaultMethodOptions: {
386
+ methodResponses: [
387
+ this.apiToEventBridgeTargetRestApi.methodResponse,
388
+ this.apiToEventBridgeTargetRestApi.methodErrorResponse,
389
+ ],
390
+ },
391
+ deploy: this.props.api.restApi?.deploy ?? true,
392
+ deployOptions: {
393
+ accessLogDestination: new LogGroupLogDestination(this.apiToEventBridgeTargetRestApi.accessLogGroup),
394
+ accessLogFormat: AccessLogFormat.jsonWithStandardFields(),
395
+ dataTraceEnabled: this.props.api.restApi?.deployOptions?.dataTraceEnabled,
396
+ description: `${this.id} - ${this.props.stage} stage`,
397
+ loggingLevel: MethodLoggingLevel.INFO,
398
+ metricsEnabled: true,
399
+ stageName: this.props.stage,
400
+ tracingEnabled: this.props.api.restApi?.deployOptions?.tracingEnabled,
419
401
  },
402
+ endpointConfiguration: {
403
+ types: [EndpointType.REGIONAL],
404
+ },
405
+ restApiName: `${this.id}-rest-api-${this.props.stage}`,
420
406
  ...this.props.api.restApi,
421
407
  })
422
408
  this.addCfnOutput(`${this.id}-restApiId`, this.apiToEventBridgeTargetRestApi.api.restApiId)
@@ -430,15 +416,13 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
430
416
  if (!this.props.api.withResource) return
431
417
  this.apiToEventBridgeTargetRestApi.responseModel = new Model(this, `${this.id}-response-model`, {
432
418
  restApi: this.apiToEventBridgeTargetRestApi.api,
433
- ...{
434
- contentType: 'application/json',
435
- modelName: 'ResponseModel',
436
- schema: {
437
- properties: { message: { type: JsonSchemaType.STRING } },
438
- schema: JsonSchemaVersion.DRAFT4,
439
- title: 'pollResponse',
440
- type: JsonSchemaType.OBJECT,
441
- },
419
+ contentType: 'application/json',
420
+ modelName: 'ResponseModel',
421
+ schema: {
422
+ properties: { message: { type: JsonSchemaType.STRING } },
423
+ schema: JsonSchemaVersion.DRAFT4,
424
+ title: 'pollResponse',
425
+ type: JsonSchemaType.OBJECT,
442
426
  },
443
427
  ...this.props.api.responseModel,
444
428
  })
@@ -451,18 +435,16 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
451
435
  if (!this.props.api.withResource) return
452
436
  this.apiToEventBridgeTargetRestApi.errorResponseModel = new Model(this, `${this.id}-error-response-model`, {
453
437
  restApi: this.apiToEventBridgeTargetRestApi.api,
454
- ...{
455
- contentType: 'application/json',
456
- modelName: 'ErrorResponseModel',
457
- schema: {
458
- properties: {
459
- message: { type: JsonSchemaType.STRING },
460
- state: { type: JsonSchemaType.STRING },
461
- },
462
- schema: JsonSchemaVersion.DRAFT4,
463
- title: 'errorResponse',
464
- type: JsonSchemaType.OBJECT,
438
+ contentType: 'application/json',
439
+ modelName: 'ErrorResponseModel',
440
+ schema: {
441
+ properties: {
442
+ message: { type: JsonSchemaType.STRING },
443
+ state: { type: JsonSchemaType.STRING },
465
444
  },
445
+ schema: JsonSchemaVersion.DRAFT4,
446
+ title: 'errorResponse',
447
+ type: JsonSchemaType.OBJECT,
466
448
  },
467
449
  ...this.props.api.errorResponseModel,
468
450
  })
@@ -240,10 +240,8 @@ export class ApiToEventBridgeTargetWithSns extends CommonConstruct {
240
240
  this,
241
241
  {
242
242
  ...this.props.lambda.function,
243
- ...{
244
- onFailure: this.apiDestinedLambda.destinationFailure,
245
- onSuccess: this.apiDestinedLambda.destinationSuccess,
246
- },
243
+ onFailure: this.apiDestinedLambda.destinationFailure,
244
+ onSuccess: this.apiDestinedLambda.destinationSuccess,
247
245
  },
248
246
  this.apiDestinedLambda.role,
249
247
  this.apiDestinedLambda.layers,
@@ -276,9 +274,7 @@ export class ApiToEventBridgeTargetWithSns extends CommonConstruct {
276
274
  protected createApiDestinationLogGroupSuccess() {
277
275
  if (this.props.api.useExisting) return
278
276
  this.apiEvent.logGroupSuccess = this.logManager.createLogGroup(`${this.id}-destination-success-log`, this, {
279
- ...{
280
- logGroupName: `/${this.id}/events/api-destination-success`,
281
- },
277
+ logGroupName: `/${this.id}/events/api-destination-success`,
282
278
  ...this.props.event.logGroupSuccess,
283
279
  })
284
280
  }
@@ -289,20 +285,18 @@ export class ApiToEventBridgeTargetWithSns extends CommonConstruct {
289
285
  protected createApiDestinationRuleSuccess() {
290
286
  if (this.props.api.useExisting) return
291
287
  this.props.event.ruleSuccess = {
292
- ...{
293
- eventPattern: {
294
- detail: {
295
- requestContext: {
296
- condition: ['Success'],
297
- },
298
- responsePayload: {
299
- source: ['custom:api-destined-lambda'],
300
- sourceId: [this.id],
301
- },
288
+ eventPattern: {
289
+ detail: {
290
+ requestContext: {
291
+ condition: ['Success'],
292
+ },
293
+ responsePayload: {
294
+ source: ['custom:api-destined-lambda'],
295
+ sourceId: [this.id],
302
296
  },
303
297
  },
304
- ruleName: `${this.id}-api-destination-success`,
305
298
  },
299
+ ruleName: `${this.id}-api-destination-success`,
306
300
  ...this.props.event.ruleSuccess,
307
301
  }
308
302
  this.apiEvent.ruleSuccess = this.eventManager.createRule(
@@ -320,9 +314,7 @@ export class ApiToEventBridgeTargetWithSns extends CommonConstruct {
320
314
  protected createApiDestinationLogGroupFailure() {
321
315
  if (this.props.api.useExisting) return
322
316
  this.apiEvent.logGroupFailure = this.logManager.createLogGroup(`${this.id}-destination-failure-log`, this, {
323
- ...{
324
- logGroupName: `/${this.id}/events/api-destination-failure`,
325
- },
317
+ logGroupName: `/${this.id}/events/api-destination-failure`,
326
318
  ...this.props.event.logGroupFailure,
327
319
  })
328
320
  }
@@ -333,16 +325,14 @@ export class ApiToEventBridgeTargetWithSns extends CommonConstruct {
333
325
  protected createApiDestinationRuleFailure() {
334
326
  if (this.props.api.useExisting) return
335
327
  this.props.event.ruleFailure = {
336
- ...{
337
- eventPattern: {
338
- detail: {
339
- responsePayload: {
340
- errorType: ['Error'],
341
- },
328
+ eventPattern: {
329
+ detail: {
330
+ responsePayload: {
331
+ errorType: ['Error'],
342
332
  },
343
333
  },
344
- ruleName: `${this.id}-api-destination-failure`,
345
334
  },
335
+ ruleName: `${this.id}-api-destination-failure`,
346
336
  ...this.props.event.ruleFailure,
347
337
  }
348
338
  this.apiEvent.ruleFailure = this.eventManager.createRule(
@@ -414,12 +404,10 @@ export class ApiToEventBridgeTargetWithSns extends CommonConstruct {
414
404
  protected createApiDestinedIntegrationResponse() {
415
405
  if (!this.props.api.withResource) return
416
406
  this.apiDestinedRestApi.integrationResponse = this.props.api.integrationResponse ?? {
417
- ...{
418
- responseTemplates: {
419
- 'application/json': JSON.stringify({ message: 'Payload Submitted' }),
420
- },
421
- statusCode: '200',
407
+ responseTemplates: {
408
+ 'application/json': JSON.stringify({ message: 'Payload Submitted' }),
422
409
  },
410
+ statusCode: '200',
423
411
  }
424
412
  }
425
413
 
@@ -429,21 +417,19 @@ export class ApiToEventBridgeTargetWithSns extends CommonConstruct {
429
417
  protected createApiDestinedIntegrationErrorResponse() {
430
418
  if (!this.props.api.withResource) return
431
419
  this.apiDestinedRestApi.integrationErrorResponse = {
432
- ...{
433
- responseParameters: {
434
- 'method.response.header.Access-Control-Allow-Credentials': "'true'",
435
- 'method.response.header.Access-Control-Allow-Origin': "'*'",
436
- 'method.response.header.Content-Type': "'application/json'",
437
- },
438
- responseTemplates: {
439
- 'application/json': JSON.stringify({
440
- message: "$util.escapeJavaScript($input.path('$.errorMessage'))",
441
- state: 'error',
442
- }),
443
- },
444
- selectionPattern: '^\\[Error\\].*',
445
- statusCode: '400',
420
+ responseParameters: {
421
+ 'method.response.header.Access-Control-Allow-Credentials': "'true'",
422
+ 'method.response.header.Access-Control-Allow-Origin': "'*'",
423
+ 'method.response.header.Content-Type': "'application/json'",
446
424
  },
425
+ responseTemplates: {
426
+ 'application/json': JSON.stringify({
427
+ message: "$util.escapeJavaScript($input.path('$.errorMessage'))",
428
+ state: 'error',
429
+ }),
430
+ },
431
+ selectionPattern: '^\\[Error\\].*',
432
+ statusCode: '400',
447
433
  ...this.props.api.integrationErrorResponse,
448
434
  }
449
435
  }
@@ -456,16 +442,14 @@ export class ApiToEventBridgeTargetWithSns extends CommonConstruct {
456
442
  this.apiDestinedRestApi.integration = new Integration({
457
443
  integrationHttpMethod: 'POST',
458
444
  options: {
459
- ...{
460
- credentialsRole: this.apiDestinedRestApi.role,
461
- integrationResponses: [
462
- this.apiDestinedRestApi.integrationResponse,
463
- this.apiDestinedRestApi.integrationErrorResponse,
464
- ],
465
- passthroughBehavior: PassthroughBehavior.NEVER,
466
- requestParameters: this.apiDestinedRestApi.integrationRequestParameters,
467
- requestTemplates: this.apiDestinedRestApi.integrationRequestTemplates,
468
- },
445
+ credentialsRole: this.apiDestinedRestApi.role,
446
+ integrationResponses: [
447
+ this.apiDestinedRestApi.integrationResponse,
448
+ this.apiDestinedRestApi.integrationErrorResponse,
449
+ ],
450
+ passthroughBehavior: PassthroughBehavior.NEVER,
451
+ requestParameters: this.apiDestinedRestApi.integrationRequestParameters,
452
+ requestTemplates: this.apiDestinedRestApi.integrationRequestTemplates,
469
453
  ...this.props.api.integrationOptions,
470
454
  },
471
455
  type: IntegrationType.AWS,
@@ -479,17 +463,15 @@ export class ApiToEventBridgeTargetWithSns extends CommonConstruct {
479
463
  protected createApiDestinedMethodResponse() {
480
464
  if (!this.props.api.withResource) return
481
465
  this.apiDestinedRestApi.methodResponse = {
482
- ...{
483
- responseModels: {
484
- 'application/json': this.apiDestinedRestApi.responseModel,
485
- },
486
- responseParameters: {
487
- 'method.response.header.Access-Control-Allow-Credentials': true,
488
- 'method.response.header.Access-Control-Allow-Origin': true,
489
- 'method.response.header.Content-Type': true,
490
- },
491
- statusCode: '200',
466
+ responseModels: {
467
+ 'application/json': this.apiDestinedRestApi.responseModel,
468
+ },
469
+ responseParameters: {
470
+ 'method.response.header.Access-Control-Allow-Credentials': true,
471
+ 'method.response.header.Access-Control-Allow-Origin': true,
472
+ 'method.response.header.Content-Type': true,
492
473
  },
474
+ statusCode: '200',
493
475
  ...this.props.api.methodResponse,
494
476
  }
495
477
  }
@@ -500,17 +482,15 @@ export class ApiToEventBridgeTargetWithSns extends CommonConstruct {
500
482
  protected createApiDestinedMethodErrorResponse() {
501
483
  if (!this.props.api.withResource) return
502
484
  this.apiDestinedRestApi.methodErrorResponse = {
503
- ...{
504
- responseModels: {
505
- 'application/json': this.apiDestinedRestApi.errorResponseModel,
506
- },
507
- responseParameters: {
508
- 'method.response.header.Access-Control-Allow-Credentials': true,
509
- 'method.response.header.Access-Control-Allow-Origin': true,
510
- 'method.response.header.Content-Type': true,
511
- },
512
- statusCode: '400',
485
+ responseModels: {
486
+ 'application/json': this.apiDestinedRestApi.errorResponseModel,
487
+ },
488
+ responseParameters: {
489
+ 'method.response.header.Access-Control-Allow-Credentials': true,
490
+ 'method.response.header.Access-Control-Allow-Origin': true,
491
+ 'method.response.header.Content-Type': true,
513
492
  },
493
+ statusCode: '400',
514
494
  ...this.props.api.methodErrorResponse,
515
495
  }
516
496
  }
@@ -534,30 +514,28 @@ export class ApiToEventBridgeTargetWithSns extends CommonConstruct {
534
514
  })
535
515
 
536
516
  this.apiDestinedRestApi.api = new RestApi(this, `${this.id}-sns-rest-api`, {
537
- ...{
538
- defaultCorsPreflightOptions: {
539
- allowHeaders: Cors.DEFAULT_HEADERS,
540
- allowMethods: ['POST'],
541
- allowOrigins: Cors.ALL_ORIGINS,
542
- },
543
- defaultIntegration: this.apiDestinedRestApi.integration,
544
- defaultMethodOptions: {
545
- methodResponses: [this.apiDestinedRestApi.methodResponse, this.apiDestinedRestApi.methodErrorResponse],
546
- },
547
- deployOptions: {
548
- accessLogDestination: new LogGroupLogDestination(accessLogGroup),
549
- accessLogFormat: AccessLogFormat.jsonWithStandardFields(),
550
- dataTraceEnabled: true,
551
- description: `${this.id} - ${this.props.stage} stage`,
552
- loggingLevel: MethodLoggingLevel.INFO,
553
- metricsEnabled: true,
554
- stageName: this.props.stage,
555
- },
556
- endpointConfiguration: {
557
- types: [EndpointType.REGIONAL],
558
- },
559
- restApiName: `${this.id}-destined-rest-api-${this.props.stage}`,
517
+ defaultCorsPreflightOptions: {
518
+ allowHeaders: Cors.DEFAULT_HEADERS,
519
+ allowMethods: ['POST'],
520
+ allowOrigins: Cors.ALL_ORIGINS,
560
521
  },
522
+ defaultIntegration: this.apiDestinedRestApi.integration,
523
+ defaultMethodOptions: {
524
+ methodResponses: [this.apiDestinedRestApi.methodResponse, this.apiDestinedRestApi.methodErrorResponse],
525
+ },
526
+ deployOptions: {
527
+ accessLogDestination: new LogGroupLogDestination(accessLogGroup),
528
+ accessLogFormat: AccessLogFormat.jsonWithStandardFields(),
529
+ dataTraceEnabled: true,
530
+ description: `${this.id} - ${this.props.stage} stage`,
531
+ loggingLevel: MethodLoggingLevel.INFO,
532
+ metricsEnabled: true,
533
+ stageName: this.props.stage,
534
+ },
535
+ endpointConfiguration: {
536
+ types: [EndpointType.REGIONAL],
537
+ },
538
+ restApiName: `${this.id}-destined-rest-api-${this.props.stage}`,
561
539
  ...this.props.api,
562
540
  })
563
541
  this.addCfnOutput(`${this.id}-restApiId`, this.apiDestinedRestApi.api.restApiId)
@@ -570,16 +548,14 @@ export class ApiToEventBridgeTargetWithSns extends CommonConstruct {
570
548
  protected createApiDestinedResponseModel() {
571
549
  if (!this.props.api.withResource) return
572
550
  this.apiDestinedRestApi.responseModel = new Model(this, `${this.id}-response-model`, {
551
+ contentType: 'application/json',
552
+ modelName: 'ResponseModel',
573
553
  restApi: this.apiDestinedRestApi.api,
574
- ...{
575
- contentType: 'application/json',
576
- modelName: 'ResponseModel',
577
- schema: {
578
- properties: { message: { type: JsonSchemaType.STRING } },
579
- schema: JsonSchemaVersion.DRAFT4,
580
- title: 'pollResponse',
581
- type: JsonSchemaType.OBJECT,
582
- },
554
+ schema: {
555
+ properties: { message: { type: JsonSchemaType.STRING } },
556
+ schema: JsonSchemaVersion.DRAFT4,
557
+ title: 'pollResponse',
558
+ type: JsonSchemaType.OBJECT,
583
559
  },
584
560
  ...this.props.api.responseModel,
585
561
  })
@@ -591,19 +567,17 @@ export class ApiToEventBridgeTargetWithSns extends CommonConstruct {
591
567
  protected createApiDestinedErrorResponseModel() {
592
568
  if (!this.props.api.withResource) return
593
569
  this.apiDestinedRestApi.errorResponseModel = new Model(this, `${this.id}-error-response-model`, {
570
+ contentType: 'application/json',
571
+ modelName: 'ErrorResponseModel',
594
572
  restApi: this.apiDestinedRestApi.api,
595
- ...{
596
- contentType: 'application/json',
597
- modelName: 'ErrorResponseModel',
598
- schema: {
599
- properties: {
600
- message: { type: JsonSchemaType.STRING },
601
- state: { type: JsonSchemaType.STRING },
602
- },
603
- schema: JsonSchemaVersion.DRAFT4,
604
- title: 'errorResponse',
605
- type: JsonSchemaType.OBJECT,
573
+ schema: {
574
+ properties: {
575
+ message: { type: JsonSchemaType.STRING },
576
+ state: { type: JsonSchemaType.STRING },
606
577
  },
578
+ schema: JsonSchemaVersion.DRAFT4,
579
+ title: 'errorResponse',
580
+ type: JsonSchemaType.OBJECT,
607
581
  },
608
582
  ...this.props.api.errorResponseModel,
609
583
  })
@@ -162,16 +162,14 @@ export class ApiToLambdaTarget extends CommonConstruct {
162
162
 
163
163
  this.props.api.restApi = {
164
164
  ...this.props.api.restApi,
165
- ...{
166
- defaultMethodOptions: {
167
- methodResponses: [
168
- this.apiToLambdaTargetRestApi.methodResponse,
169
- this.apiToLambdaTargetRestApi.methodErrorResponse,
170
- ],
171
- },
172
- deployOptions: {
173
- accessLogDestination: new LogGroupLogDestination(accessLogGroup),
174
- },
165
+ defaultMethodOptions: {
166
+ methodResponses: [
167
+ this.apiToLambdaTargetRestApi.methodResponse,
168
+ this.apiToLambdaTargetRestApi.methodErrorResponse,
169
+ ],
170
+ },
171
+ deployOptions: {
172
+ accessLogDestination: new LogGroupLogDestination(accessLogGroup),
175
173
  },
176
174
  }
177
175
 
@@ -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 { GraphQlApiLambdaEnvironment, GraphQlApiLambdaProps } from './types'
10
11
 
@@ -151,7 +152,7 @@ export class GraphQLApiLambda extends CommonConstruct {
151
152
 
152
153
  if (!this.props.graphqlApiLambdaLayerSources) return
153
154
 
154
- this.props.graphqlApiLambdaLayerSources.forEach((source: AssetCode, index: number) => {
155
+ _.forEach(this.props.graphqlApiLambdaLayerSources, (source: AssetCode, index: number) => {
155
156
  layers.push(this.lambdaManager.createLambdaLayer(`${this.id}-layer-${index}`, this, source))
156
157
  })
157
158
 
@@ -205,8 +206,8 @@ export class GraphQLApiLambda extends CommonConstruct {
205
206
  */
206
207
  protected createApiBasePathMapping() {
207
208
  const apiRootPaths = this.props.apiRootPaths
208
- if (apiRootPaths && apiRootPaths.length > 0) {
209
- apiRootPaths.forEach((apiRootPath: string) => {
209
+ if (apiRootPaths && !_.isEmpty(apiRootPaths)) {
210
+ _.forEach(apiRootPaths, (apiRootPath: string) => {
210
211
  this.graphQLApiBasePathMappings.push(
211
212
  new BasePathMapping(this, `${this.id}-base-bath-mapping-${apiRootPath}`, {
212
213
  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 { GraphQLApiLambda } from '..'
7
8
  import * as utils from '../../utils'
8
9
  import { GraphQlApiLambdaWithCacheProps } from './types'
@@ -91,7 +92,7 @@ export class GraphQLApiLambdaWithCache extends GraphQLApiLambda {
91
92
  `${this.id}-elasticache`,
92
93
  this,
93
94
  this.props.graphQLElastiCache,
94
- this.graphQLVpc.privateSubnets.map(subnet => subnet.subnetId),
95
+ _.map(this.graphQLVpc.privateSubnets, subnet => subnet.subnetId),
95
96
  [this.graphQLSecurityGroup.securityGroupId]
96
97
  )
97
98
  }
@@ -4,6 +4,7 @@ import { CfnAccessKey, Policy, PolicyDocument, PolicyStatement, Role, User } fro
4
4
  import { AssetCode, IFunction, ILayerVersion, LayerVersion } from 'aws-cdk-lib/aws-lambda'
5
5
  import { CfnSecret, Secret } from 'aws-cdk-lib/aws-secretsmanager'
6
6
  import { Construct } from 'constructs'
7
+ import _ from 'lodash'
7
8
  import { CommonConstruct } from '../../common'
8
9
  import { LambdaWithIamAccessEnvironment, LambdaWithIamAccessProps } from './types'
9
10
 
@@ -112,7 +113,7 @@ export class LambdaWithIamAccess extends CommonConstruct {
112
113
 
113
114
  if (!this.props.lambdaLayerSources) return
114
115
 
115
- this.props.lambdaLayerSources.forEach((source: AssetCode, index: number) => {
116
+ _.forEach(this.props.lambdaLayerSources, (source: AssetCode, index: number) => {
116
117
  layers.push(this.lambdaManager.createLambdaLayer(`${this.id}-layer-${index}`, this, source))
117
118
  })
118
119