@gradientedge/cdk-utils 8.122.0 → 8.123.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.
- package/dist/src/lib/aws/common/stack.js +5 -7
- package/dist/src/lib/aws/construct/api-to-any-target/main.js +24 -26
- package/dist/src/lib/aws/construct/api-to-eventbridge-target/main.js +85 -103
- package/dist/src/lib/aws/construct/api-to-eventbridge-target-with-sns/main.js +94 -120
- package/dist/src/lib/aws/construct/api-to-lambda-target/main.js +8 -10
- package/dist/src/lib/aws/construct/graphql-api-lambda/main.js +7 -3
- package/dist/src/lib/aws/construct/graphql-api-lambda-with-cache/main.js +5 -1
- package/dist/src/lib/aws/construct/lambda-with-iam-access/main.js +5 -1
- package/dist/src/lib/aws/construct/rest-api-lambda/main.js +7 -3
- package/dist/src/lib/aws/construct/rest-api-lambda-with-cache/main.js +5 -1
- package/dist/src/lib/aws/construct/site-with-ecs-backend/main.js +8 -6
- package/dist/src/lib/aws/construct/static-asset-deployment/main.js +5 -1
- package/dist/src/lib/aws/services/api-gateway/main.js +18 -10
- package/dist/src/lib/aws/services/cloudfront/main.js +11 -7
- package/dist/src/lib/aws/services/cloudwatch/logs.js +8 -4
- package/dist/src/lib/aws/services/cloudwatch/main.js +36 -78
- package/dist/src/lib/aws/services/dynamodb/main.js +6 -2
- package/dist/src/lib/aws/services/elastic-container-service/main.js +8 -4
- package/dist/src/lib/aws/services/elastic-file-system/main.js +5 -1
- package/dist/src/lib/aws/services/elasticache/main.js +6 -2
- package/dist/src/lib/aws/services/eventbridge/main.js +8 -4
- package/dist/src/lib/aws/services/lambda/main.js +7 -3
- package/dist/src/lib/aws/services/simple-notification-service/main.js +6 -2
- package/dist/src/lib/aws/services/simple-queue-service/main.js +6 -2
- package/dist/src/lib/aws/services/simple-storage-service/main.js +8 -4
- package/dist/src/lib/aws/services/step-function/main.js +52 -32
- package/dist/src/lib/aws/services/virtual-private-cloud/main.js +8 -4
- package/dist/src/lib/azure/common/stack.js +5 -7
- package/dist/src/lib/common/index.js +7 -3
- package/package.json +8 -8
- package/src/lib/aws/common/stack.ts +5 -7
- package/src/lib/aws/construct/api-to-any-target/main.ts +25 -27
- package/src/lib/aws/construct/api-to-eventbridge-target/main.ts +85 -103
- package/src/lib/aws/construct/api-to-eventbridge-target-with-sns/main.ts +94 -120
- package/src/lib/aws/construct/api-to-lambda-target/main.ts +8 -10
- package/src/lib/aws/construct/graphql-api-lambda/main.ts +4 -3
- package/src/lib/aws/construct/graphql-api-lambda-with-cache/main.ts +2 -1
- package/src/lib/aws/construct/lambda-with-iam-access/main.ts +2 -1
- package/src/lib/aws/construct/rest-api-lambda/main.ts +4 -3
- package/src/lib/aws/construct/rest-api-lambda-with-cache/main.ts +2 -1
- package/src/lib/aws/construct/site-with-ecs-backend/main.ts +8 -9
- package/src/lib/aws/construct/static-asset-deployment/main.ts +2 -1
- package/src/lib/aws/services/api-gateway/main.ts +9 -6
- package/src/lib/aws/services/cloudfront/main.ts +8 -7
- package/src/lib/aws/services/cloudwatch/logs.ts +6 -5
- package/src/lib/aws/services/cloudwatch/main.ts +35 -81
- package/src/lib/aws/services/dynamodb/main.ts +3 -2
- package/src/lib/aws/services/elastic-container-service/main.ts +5 -4
- package/src/lib/aws/services/elastic-file-system/main.ts +2 -1
- package/src/lib/aws/services/elasticache/main.ts +3 -2
- package/src/lib/aws/services/eventbridge/main.ts +5 -4
- package/src/lib/aws/services/lambda/main.ts +4 -3
- package/src/lib/aws/services/simple-notification-service/main.ts +3 -2
- package/src/lib/aws/services/simple-queue-service/main.ts +3 -2
- package/src/lib/aws/services/simple-storage-service/main.ts +5 -4
- package/src/lib/aws/services/step-function/main.ts +17 -16
- package/src/lib/aws/services/virtual-private-cloud/main.ts +5 -4
- package/src/lib/azure/common/stack.ts +7 -9
- package/src/lib/common/index.ts +5 -3
|
@@ -240,10 +240,8 @@ export class ApiToEventBridgeTargetWithSns extends CommonConstruct {
|
|
|
240
240
|
this,
|
|
241
241
|
{
|
|
242
242
|
...this.props.lambda.function,
|
|
243
|
-
|
|
244
|
-
|
|
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
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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
|
-
|
|
338
|
-
|
|
339
|
-
|
|
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
|
-
|
|
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
|
-
|
|
434
|
-
|
|
435
|
-
|
|
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
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
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
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
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
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
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
|
-
|
|
539
|
-
|
|
540
|
-
|
|
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
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
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
|
-
|
|
597
|
-
|
|
598
|
-
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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
|
|
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
|
|
209
|
-
|
|
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
|
|
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
|
|
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
|
|
|
@@ -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
|
|
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
|
|
212
|
-
|
|
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
|
|
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
|
|
409
|
-
this.props.siteTask.mountPoints
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
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
|
-
|
|
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
|
|
87
|
-
props.tags
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
119
|
-
props.tags
|
|
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
|
|
184
|
-
props.tags
|
|
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
|
|
248
|
-
props.tags
|
|
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
|
|
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
|
|
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
|
|
70
|
-
props.tags
|
|
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
|
|
97
|
-
props.tags
|
|
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
|
}
|