@gradientedge/cdk-utils 8.121.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/README.md +2 -1
- package/dist/src/lib/aws/common/construct.d.ts +0 -1
- package/dist/src/lib/aws/common/construct.js +6 -13
- package/dist/src/lib/aws/common/stack.js +7 -9
- package/dist/src/lib/aws/common/types.d.ts +2 -8
- 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/aws/types/index.d.ts +6 -1
- package/dist/src/lib/aws/types/index.js +0 -15
- package/dist/src/lib/aws/utils/index.d.ts +13 -23
- package/dist/src/lib/aws/utils/index.js +37 -46
- package/dist/src/lib/azure/common/construct.d.ts +35 -0
- package/dist/src/lib/azure/common/construct.js +49 -0
- package/dist/src/lib/azure/common/index.d.ts +3 -0
- package/dist/src/lib/azure/common/index.js +19 -0
- package/dist/src/lib/azure/common/stack.d.ts +52 -0
- package/dist/src/lib/azure/common/stack.js +134 -0
- package/dist/src/lib/azure/common/types.d.ts +7 -0
- package/dist/src/lib/azure/index.d.ts +4 -0
- package/dist/src/lib/azure/index.js +20 -0
- package/dist/src/lib/azure/services/index.d.ts +1 -0
- package/dist/src/lib/azure/services/index.js +17 -0
- package/dist/src/lib/azure/services/storage/index.d.ts +2 -0
- package/dist/src/lib/azure/services/storage/index.js +18 -0
- package/dist/src/lib/azure/services/storage/main.d.ts +43 -0
- package/dist/src/lib/azure/services/storage/main.js +124 -0
- package/dist/src/lib/azure/services/storage/types.d.ts +10 -0
- package/dist/src/lib/azure/services/storage/types.js +2 -0
- package/dist/src/lib/azure/types/index.d.ts +3 -0
- package/dist/src/lib/azure/types/index.js +2 -0
- package/dist/src/lib/azure/utils/index.d.ts +3 -0
- package/dist/src/lib/azure/utils/index.js +20 -0
- package/dist/src/lib/common/construct.d.ts +29 -0
- package/dist/src/lib/common/construct.js +8 -0
- package/dist/src/lib/common/index.d.ts +5 -0
- package/dist/src/lib/common/index.js +33 -0
- package/dist/src/lib/common/stack.d.ts +21 -0
- package/dist/src/lib/common/stack.js +8 -0
- package/dist/src/lib/common/types.d.ts +9 -0
- package/dist/src/lib/common/types.js +2 -0
- package/dist/src/lib/common/utils.d.ts +26 -0
- package/dist/src/lib/common/utils.js +34 -0
- package/dist/src/lib/index.d.ts +2 -0
- package/dist/src/lib/index.js +2 -0
- package/package.json +9 -7
- package/setup.js +2 -0
- package/src/lib/aws/common/construct.ts +2 -13
- package/src/lib/aws/common/stack.ts +6 -8
- package/src/lib/aws/common/types.ts +2 -8
- 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/aws/types/index.ts +6 -1
- package/src/lib/aws/utils/index.ts +41 -29
- package/src/lib/azure/common/construct.ts +57 -0
- package/src/lib/azure/common/index.ts +3 -0
- package/src/lib/azure/common/stack.ts +143 -0
- package/src/lib/azure/common/types.ts +8 -0
- package/src/lib/azure/index.ts +4 -0
- package/src/lib/azure/services/index.ts +1 -0
- package/src/lib/azure/services/storage/index.ts +2 -0
- package/src/lib/azure/services/storage/main.ts +134 -0
- package/src/lib/azure/services/storage/types.ts +10 -0
- package/src/lib/azure/types/index.ts +3 -0
- package/src/lib/azure/utils/index.ts +23 -0
- package/src/lib/common/construct.ts +35 -0
- package/src/lib/common/index.ts +18 -0
- package/src/lib/common/stack.ts +26 -0
- package/src/lib/common/types.ts +9 -0
- package/src/lib/common/utils.ts +27 -0
- package/src/lib/index.ts +2 -0
- package/dist/src/lib/aws/types/aws/index.d.ts +0 -6
- package/dist/src/lib/aws/utils/aws/index.d.ts +0 -17
- package/dist/src/lib/aws/utils/aws/index.js +0 -40
- package/src/lib/aws/types/aws/index.ts +0 -6
- package/src/lib/aws/utils/aws/index.ts +0 -41
- /package/dist/src/lib/{aws/types/aws/index.js → azure/common/types.js} +0 -0
|
@@ -176,10 +176,8 @@ class ApiToEventBridgeTargetWithSns extends common_1.CommonConstruct {
|
|
|
176
176
|
throw 'Api Destined Lambda props undefined';
|
|
177
177
|
this.apiDestinedLambda.function = this.lambdaManager.createLambdaFunction(`${this.id}-lambda-destined`, this, {
|
|
178
178
|
...this.props.lambda.function,
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
onSuccess: this.apiDestinedLambda.destinationSuccess,
|
|
182
|
-
},
|
|
179
|
+
onFailure: this.apiDestinedLambda.destinationFailure,
|
|
180
|
+
onSuccess: this.apiDestinedLambda.destinationSuccess,
|
|
183
181
|
}, this.apiDestinedLambda.role, this.apiDestinedLambda.layers, this.props.lambda.source, this.props.lambda.handler ?? 'lambda.handler', this.apiDestinedLambda.environment);
|
|
184
182
|
}
|
|
185
183
|
/**
|
|
@@ -201,9 +199,7 @@ class ApiToEventBridgeTargetWithSns extends common_1.CommonConstruct {
|
|
|
201
199
|
if (this.props.api.useExisting)
|
|
202
200
|
return;
|
|
203
201
|
this.apiEvent.logGroupSuccess = this.logManager.createLogGroup(`${this.id}-destination-success-log`, this, {
|
|
204
|
-
|
|
205
|
-
logGroupName: `/${this.id}/events/api-destination-success`,
|
|
206
|
-
},
|
|
202
|
+
logGroupName: `/${this.id}/events/api-destination-success`,
|
|
207
203
|
...this.props.event.logGroupSuccess,
|
|
208
204
|
});
|
|
209
205
|
}
|
|
@@ -214,20 +210,18 @@ class ApiToEventBridgeTargetWithSns extends common_1.CommonConstruct {
|
|
|
214
210
|
if (this.props.api.useExisting)
|
|
215
211
|
return;
|
|
216
212
|
this.props.event.ruleSuccess = {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
sourceId: [this.id],
|
|
226
|
-
},
|
|
213
|
+
eventPattern: {
|
|
214
|
+
detail: {
|
|
215
|
+
requestContext: {
|
|
216
|
+
condition: ['Success'],
|
|
217
|
+
},
|
|
218
|
+
responsePayload: {
|
|
219
|
+
source: ['custom:api-destined-lambda'],
|
|
220
|
+
sourceId: [this.id],
|
|
227
221
|
},
|
|
228
222
|
},
|
|
229
|
-
ruleName: `${this.id}-api-destination-success`,
|
|
230
223
|
},
|
|
224
|
+
ruleName: `${this.id}-api-destination-success`,
|
|
231
225
|
...this.props.event.ruleSuccess,
|
|
232
226
|
};
|
|
233
227
|
this.apiEvent.ruleSuccess = this.eventManager.createRule(`${this.id}-api-destination-rule-success`, this, this.props.event.ruleSuccess, this.apiEvent.eventBus, [new aws_events_targets_1.CloudWatchLogGroup(this.apiEvent.logGroupSuccess)]);
|
|
@@ -239,9 +233,7 @@ class ApiToEventBridgeTargetWithSns extends common_1.CommonConstruct {
|
|
|
239
233
|
if (this.props.api.useExisting)
|
|
240
234
|
return;
|
|
241
235
|
this.apiEvent.logGroupFailure = this.logManager.createLogGroup(`${this.id}-destination-failure-log`, this, {
|
|
242
|
-
|
|
243
|
-
logGroupName: `/${this.id}/events/api-destination-failure`,
|
|
244
|
-
},
|
|
236
|
+
logGroupName: `/${this.id}/events/api-destination-failure`,
|
|
245
237
|
...this.props.event.logGroupFailure,
|
|
246
238
|
});
|
|
247
239
|
}
|
|
@@ -252,16 +244,14 @@ class ApiToEventBridgeTargetWithSns extends common_1.CommonConstruct {
|
|
|
252
244
|
if (this.props.api.useExisting)
|
|
253
245
|
return;
|
|
254
246
|
this.props.event.ruleFailure = {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
errorType: ['Error'],
|
|
260
|
-
},
|
|
247
|
+
eventPattern: {
|
|
248
|
+
detail: {
|
|
249
|
+
responsePayload: {
|
|
250
|
+
errorType: ['Error'],
|
|
261
251
|
},
|
|
262
252
|
},
|
|
263
|
-
ruleName: `${this.id}-api-destination-failure`,
|
|
264
253
|
},
|
|
254
|
+
ruleName: `${this.id}-api-destination-failure`,
|
|
265
255
|
...this.props.event.ruleFailure,
|
|
266
256
|
};
|
|
267
257
|
this.apiEvent.ruleFailure = this.eventManager.createRule(`${this.id}-api-destination-rule-failure`, this, this.props.event.ruleFailure, this.apiEvent.eventBus, [new aws_events_targets_1.CloudWatchLogGroup(this.apiEvent.logGroupFailure)]);
|
|
@@ -321,12 +311,10 @@ class ApiToEventBridgeTargetWithSns extends common_1.CommonConstruct {
|
|
|
321
311
|
if (!this.props.api.withResource)
|
|
322
312
|
return;
|
|
323
313
|
this.apiDestinedRestApi.integrationResponse = this.props.api.integrationResponse ?? {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
'application/json': JSON.stringify({ message: 'Payload Submitted' }),
|
|
327
|
-
},
|
|
328
|
-
statusCode: '200',
|
|
314
|
+
responseTemplates: {
|
|
315
|
+
'application/json': JSON.stringify({ message: 'Payload Submitted' }),
|
|
329
316
|
},
|
|
317
|
+
statusCode: '200',
|
|
330
318
|
};
|
|
331
319
|
}
|
|
332
320
|
/**
|
|
@@ -336,21 +324,19 @@ class ApiToEventBridgeTargetWithSns extends common_1.CommonConstruct {
|
|
|
336
324
|
if (!this.props.api.withResource)
|
|
337
325
|
return;
|
|
338
326
|
this.apiDestinedRestApi.integrationErrorResponse = {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
}),
|
|
350
|
-
},
|
|
351
|
-
selectionPattern: '^\\[Error\\].*',
|
|
352
|
-
statusCode: '400',
|
|
327
|
+
responseParameters: {
|
|
328
|
+
'method.response.header.Access-Control-Allow-Credentials': "'true'",
|
|
329
|
+
'method.response.header.Access-Control-Allow-Origin': "'*'",
|
|
330
|
+
'method.response.header.Content-Type': "'application/json'",
|
|
331
|
+
},
|
|
332
|
+
responseTemplates: {
|
|
333
|
+
'application/json': JSON.stringify({
|
|
334
|
+
message: "$util.escapeJavaScript($input.path('$.errorMessage'))",
|
|
335
|
+
state: 'error',
|
|
336
|
+
}),
|
|
353
337
|
},
|
|
338
|
+
selectionPattern: '^\\[Error\\].*',
|
|
339
|
+
statusCode: '400',
|
|
354
340
|
...this.props.api.integrationErrorResponse,
|
|
355
341
|
};
|
|
356
342
|
}
|
|
@@ -363,16 +349,14 @@ class ApiToEventBridgeTargetWithSns extends common_1.CommonConstruct {
|
|
|
363
349
|
this.apiDestinedRestApi.integration = new aws_apigateway_1.Integration({
|
|
364
350
|
integrationHttpMethod: 'POST',
|
|
365
351
|
options: {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
requestTemplates: this.apiDestinedRestApi.integrationRequestTemplates,
|
|
375
|
-
},
|
|
352
|
+
credentialsRole: this.apiDestinedRestApi.role,
|
|
353
|
+
integrationResponses: [
|
|
354
|
+
this.apiDestinedRestApi.integrationResponse,
|
|
355
|
+
this.apiDestinedRestApi.integrationErrorResponse,
|
|
356
|
+
],
|
|
357
|
+
passthroughBehavior: aws_apigateway_1.PassthroughBehavior.NEVER,
|
|
358
|
+
requestParameters: this.apiDestinedRestApi.integrationRequestParameters,
|
|
359
|
+
requestTemplates: this.apiDestinedRestApi.integrationRequestTemplates,
|
|
376
360
|
...this.props.api.integrationOptions,
|
|
377
361
|
},
|
|
378
362
|
type: aws_apigateway_1.IntegrationType.AWS,
|
|
@@ -386,17 +370,15 @@ class ApiToEventBridgeTargetWithSns extends common_1.CommonConstruct {
|
|
|
386
370
|
if (!this.props.api.withResource)
|
|
387
371
|
return;
|
|
388
372
|
this.apiDestinedRestApi.methodResponse = {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
'method.response.header.Content-Type': true,
|
|
397
|
-
},
|
|
398
|
-
statusCode: '200',
|
|
373
|
+
responseModels: {
|
|
374
|
+
'application/json': this.apiDestinedRestApi.responseModel,
|
|
375
|
+
},
|
|
376
|
+
responseParameters: {
|
|
377
|
+
'method.response.header.Access-Control-Allow-Credentials': true,
|
|
378
|
+
'method.response.header.Access-Control-Allow-Origin': true,
|
|
379
|
+
'method.response.header.Content-Type': true,
|
|
399
380
|
},
|
|
381
|
+
statusCode: '200',
|
|
400
382
|
...this.props.api.methodResponse,
|
|
401
383
|
};
|
|
402
384
|
}
|
|
@@ -407,17 +389,15 @@ class ApiToEventBridgeTargetWithSns extends common_1.CommonConstruct {
|
|
|
407
389
|
if (!this.props.api.withResource)
|
|
408
390
|
return;
|
|
409
391
|
this.apiDestinedRestApi.methodErrorResponse = {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
'method.response.header.Content-Type': true,
|
|
418
|
-
},
|
|
419
|
-
statusCode: '400',
|
|
392
|
+
responseModels: {
|
|
393
|
+
'application/json': this.apiDestinedRestApi.errorResponseModel,
|
|
394
|
+
},
|
|
395
|
+
responseParameters: {
|
|
396
|
+
'method.response.header.Access-Control-Allow-Credentials': true,
|
|
397
|
+
'method.response.header.Access-Control-Allow-Origin': true,
|
|
398
|
+
'method.response.header.Content-Type': true,
|
|
420
399
|
},
|
|
400
|
+
statusCode: '400',
|
|
421
401
|
...this.props.api.methodErrorResponse,
|
|
422
402
|
};
|
|
423
403
|
}
|
|
@@ -434,30 +414,28 @@ class ApiToEventBridgeTargetWithSns extends common_1.CommonConstruct {
|
|
|
434
414
|
removalPolicy: aws_cdk_lib_1.RemovalPolicy.DESTROY,
|
|
435
415
|
});
|
|
436
416
|
this.apiDestinedRestApi.api = new aws_apigateway_1.RestApi(this, `${this.id}-sns-rest-api`, {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
stageName: this.props.stage,
|
|
455
|
-
},
|
|
456
|
-
endpointConfiguration: {
|
|
457
|
-
types: [aws_apigateway_1.EndpointType.REGIONAL],
|
|
458
|
-
},
|
|
459
|
-
restApiName: `${this.id}-destined-rest-api-${this.props.stage}`,
|
|
417
|
+
defaultCorsPreflightOptions: {
|
|
418
|
+
allowHeaders: aws_apigateway_1.Cors.DEFAULT_HEADERS,
|
|
419
|
+
allowMethods: ['POST'],
|
|
420
|
+
allowOrigins: aws_apigateway_1.Cors.ALL_ORIGINS,
|
|
421
|
+
},
|
|
422
|
+
defaultIntegration: this.apiDestinedRestApi.integration,
|
|
423
|
+
defaultMethodOptions: {
|
|
424
|
+
methodResponses: [this.apiDestinedRestApi.methodResponse, this.apiDestinedRestApi.methodErrorResponse],
|
|
425
|
+
},
|
|
426
|
+
deployOptions: {
|
|
427
|
+
accessLogDestination: new aws_apigateway_1.LogGroupLogDestination(accessLogGroup),
|
|
428
|
+
accessLogFormat: aws_apigateway_1.AccessLogFormat.jsonWithStandardFields(),
|
|
429
|
+
dataTraceEnabled: true,
|
|
430
|
+
description: `${this.id} - ${this.props.stage} stage`,
|
|
431
|
+
loggingLevel: aws_apigateway_1.MethodLoggingLevel.INFO,
|
|
432
|
+
metricsEnabled: true,
|
|
433
|
+
stageName: this.props.stage,
|
|
460
434
|
},
|
|
435
|
+
endpointConfiguration: {
|
|
436
|
+
types: [aws_apigateway_1.EndpointType.REGIONAL],
|
|
437
|
+
},
|
|
438
|
+
restApiName: `${this.id}-destined-rest-api-${this.props.stage}`,
|
|
461
439
|
...this.props.api,
|
|
462
440
|
});
|
|
463
441
|
this.addCfnOutput(`${this.id}-restApiId`, this.apiDestinedRestApi.api.restApiId);
|
|
@@ -470,16 +448,14 @@ class ApiToEventBridgeTargetWithSns extends common_1.CommonConstruct {
|
|
|
470
448
|
if (!this.props.api.withResource)
|
|
471
449
|
return;
|
|
472
450
|
this.apiDestinedRestApi.responseModel = new aws_apigateway_1.Model(this, `${this.id}-response-model`, {
|
|
451
|
+
contentType: 'application/json',
|
|
452
|
+
modelName: 'ResponseModel',
|
|
473
453
|
restApi: this.apiDestinedRestApi.api,
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
schema: aws_apigateway_1.JsonSchemaVersion.DRAFT4,
|
|
480
|
-
title: 'pollResponse',
|
|
481
|
-
type: aws_apigateway_1.JsonSchemaType.OBJECT,
|
|
482
|
-
},
|
|
454
|
+
schema: {
|
|
455
|
+
properties: { message: { type: aws_apigateway_1.JsonSchemaType.STRING } },
|
|
456
|
+
schema: aws_apigateway_1.JsonSchemaVersion.DRAFT4,
|
|
457
|
+
title: 'pollResponse',
|
|
458
|
+
type: aws_apigateway_1.JsonSchemaType.OBJECT,
|
|
483
459
|
},
|
|
484
460
|
...this.props.api.responseModel,
|
|
485
461
|
});
|
|
@@ -491,19 +467,17 @@ class ApiToEventBridgeTargetWithSns extends common_1.CommonConstruct {
|
|
|
491
467
|
if (!this.props.api.withResource)
|
|
492
468
|
return;
|
|
493
469
|
this.apiDestinedRestApi.errorResponseModel = new aws_apigateway_1.Model(this, `${this.id}-error-response-model`, {
|
|
470
|
+
contentType: 'application/json',
|
|
471
|
+
modelName: 'ErrorResponseModel',
|
|
494
472
|
restApi: this.apiDestinedRestApi.api,
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
properties: {
|
|
500
|
-
message: { type: aws_apigateway_1.JsonSchemaType.STRING },
|
|
501
|
-
state: { type: aws_apigateway_1.JsonSchemaType.STRING },
|
|
502
|
-
},
|
|
503
|
-
schema: aws_apigateway_1.JsonSchemaVersion.DRAFT4,
|
|
504
|
-
title: 'errorResponse',
|
|
505
|
-
type: aws_apigateway_1.JsonSchemaType.OBJECT,
|
|
473
|
+
schema: {
|
|
474
|
+
properties: {
|
|
475
|
+
message: { type: aws_apigateway_1.JsonSchemaType.STRING },
|
|
476
|
+
state: { type: aws_apigateway_1.JsonSchemaType.STRING },
|
|
506
477
|
},
|
|
478
|
+
schema: aws_apigateway_1.JsonSchemaVersion.DRAFT4,
|
|
479
|
+
title: 'errorResponse',
|
|
480
|
+
type: aws_apigateway_1.JsonSchemaType.OBJECT,
|
|
507
481
|
},
|
|
508
482
|
...this.props.api.errorResponseModel,
|
|
509
483
|
});
|
|
@@ -119,16 +119,14 @@ class ApiToLambdaTarget extends common_1.CommonConstruct {
|
|
|
119
119
|
});
|
|
120
120
|
this.props.api.restApi = {
|
|
121
121
|
...this.props.api.restApi,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
accessLogDestination: new aws_apigateway_1.LogGroupLogDestination(accessLogGroup),
|
|
131
|
-
},
|
|
122
|
+
defaultMethodOptions: {
|
|
123
|
+
methodResponses: [
|
|
124
|
+
this.apiToLambdaTargetRestApi.methodResponse,
|
|
125
|
+
this.apiToLambdaTargetRestApi.methodErrorResponse,
|
|
126
|
+
],
|
|
127
|
+
},
|
|
128
|
+
deployOptions: {
|
|
129
|
+
accessLogDestination: new aws_apigateway_1.LogGroupLogDestination(accessLogGroup),
|
|
132
130
|
},
|
|
133
131
|
};
|
|
134
132
|
this.apiToLambdaTargetRestApi.api = this.apiManager.createLambdaRestApi(`${this.id}-lambda-rest-api`, this, this.props.api.restApi, this.apiToLambdaTargetRestApi.lambda);
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.GraphQLApiLambda = void 0;
|
|
4
7
|
const aws_apigateway_1 = require("aws-cdk-lib/aws-apigateway");
|
|
5
8
|
const aws_iam_1 = require("aws-cdk-lib/aws-iam");
|
|
9
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
6
10
|
const common_1 = require("../../common");
|
|
7
11
|
/**
|
|
8
12
|
* @deprecated Use RestApiLambda instead. This will be removed in a future release.
|
|
@@ -115,7 +119,7 @@ class GraphQLApiLambda extends common_1.CommonConstruct {
|
|
|
115
119
|
const layers = [];
|
|
116
120
|
if (!this.props.graphqlApiLambdaLayerSources)
|
|
117
121
|
return;
|
|
118
|
-
this.props.graphqlApiLambdaLayerSources
|
|
122
|
+
lodash_1.default.forEach(this.props.graphqlApiLambdaLayerSources, (source, index) => {
|
|
119
123
|
layers.push(this.lambdaManager.createLambdaLayer(`${this.id}-layer-${index}`, this, source));
|
|
120
124
|
});
|
|
121
125
|
this.graphQLApiLambdaLayers = layers;
|
|
@@ -145,8 +149,8 @@ class GraphQLApiLambda extends common_1.CommonConstruct {
|
|
|
145
149
|
*/
|
|
146
150
|
createApiBasePathMapping() {
|
|
147
151
|
const apiRootPaths = this.props.apiRootPaths;
|
|
148
|
-
if (apiRootPaths && apiRootPaths
|
|
149
|
-
|
|
152
|
+
if (apiRootPaths && !lodash_1.default.isEmpty(apiRootPaths)) {
|
|
153
|
+
lodash_1.default.forEach(apiRootPaths, (apiRootPath) => {
|
|
150
154
|
this.graphQLApiBasePathMappings.push(new aws_apigateway_1.BasePathMapping(this, `${this.id}-base-bath-mapping-${apiRootPath}`, {
|
|
151
155
|
basePath: apiRootPath,
|
|
152
156
|
domainName: this.graphQLApiDomain,
|
|
@@ -22,11 +22,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
29
|
exports.GraphQLApiLambdaWithCache = void 0;
|
|
27
30
|
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
28
31
|
const aws_ec2_1 = require("aws-cdk-lib/aws-ec2");
|
|
29
32
|
const aws_iam_1 = require("aws-cdk-lib/aws-iam");
|
|
33
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
30
34
|
const __1 = require("..");
|
|
31
35
|
const utils = __importStar(require("../../utils"));
|
|
32
36
|
/**
|
|
@@ -98,7 +102,7 @@ class GraphQLApiLambdaWithCache extends __1.GraphQLApiLambda {
|
|
|
98
102
|
* Create ElastiCache
|
|
99
103
|
*/
|
|
100
104
|
createElastiCache() {
|
|
101
|
-
this.graphQLElastiCache = this.elasticacheManager.createReplicatedElastiCache(`${this.id}-elasticache`, this, this.props.graphQLElastiCache, this.graphQLVpc.privateSubnets
|
|
105
|
+
this.graphQLElastiCache = this.elasticacheManager.createReplicatedElastiCache(`${this.id}-elasticache`, this, this.props.graphQLElastiCache, lodash_1.default.map(this.graphQLVpc.privateSubnets, subnet => subnet.subnetId), [this.graphQLSecurityGroup.securityGroupId]);
|
|
102
106
|
}
|
|
103
107
|
/**
|
|
104
108
|
* Create Lambda Role
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.LambdaWithIamAccess = void 0;
|
|
4
7
|
const aws_iam_1 = require("aws-cdk-lib/aws-iam");
|
|
5
8
|
const aws_secretsmanager_1 = require("aws-cdk-lib/aws-secretsmanager");
|
|
9
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
6
10
|
const common_1 = require("../../common");
|
|
7
11
|
/**
|
|
8
12
|
* @classdesc Provides a construct to create a lambda function with IAM access
|
|
@@ -95,7 +99,7 @@ class LambdaWithIamAccess extends common_1.CommonConstruct {
|
|
|
95
99
|
const layers = [];
|
|
96
100
|
if (!this.props.lambdaLayerSources)
|
|
97
101
|
return;
|
|
98
|
-
this.props.lambdaLayerSources
|
|
102
|
+
lodash_1.default.forEach(this.props.lambdaLayerSources, (source, index) => {
|
|
99
103
|
layers.push(this.lambdaManager.createLambdaLayer(`${this.id}-layer-${index}`, this, source));
|
|
100
104
|
});
|
|
101
105
|
this.lambdaLayers = layers;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.RestApiLambda = void 0;
|
|
4
7
|
const aws_apigateway_1 = require("aws-cdk-lib/aws-apigateway");
|
|
5
8
|
const aws_iam_1 = require("aws-cdk-lib/aws-iam");
|
|
9
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
6
10
|
const common_1 = require("../../common");
|
|
7
11
|
/**
|
|
8
12
|
* @classdesc Provides a construct to create and deploy a RestApi as Lambda
|
|
@@ -116,7 +120,7 @@ class RestApiLambda extends common_1.CommonConstruct {
|
|
|
116
120
|
const layers = [];
|
|
117
121
|
if (!this.props.restApiLambdaLayerSources)
|
|
118
122
|
return;
|
|
119
|
-
this.props.restApiLambdaLayerSources
|
|
123
|
+
lodash_1.default.forEach(this.props.restApiLambdaLayerSources, (source, index) => {
|
|
120
124
|
layers.push(this.lambdaManager.createLambdaLayer(`${this.id}-layer-${index}`, this, source));
|
|
121
125
|
});
|
|
122
126
|
this.restApiLambdaLayers = layers;
|
|
@@ -146,8 +150,8 @@ class RestApiLambda extends common_1.CommonConstruct {
|
|
|
146
150
|
*/
|
|
147
151
|
createApiBasePathMapping() {
|
|
148
152
|
const apiRootPaths = this.props.apiRootPaths;
|
|
149
|
-
if (apiRootPaths && apiRootPaths
|
|
150
|
-
|
|
153
|
+
if (apiRootPaths && !lodash_1.default.isEmpty(apiRootPaths)) {
|
|
154
|
+
lodash_1.default.forEach(apiRootPaths, (apiRootPath) => {
|
|
151
155
|
this.restApiBasePathMappings.push(new aws_apigateway_1.BasePathMapping(this, `${this.id}-base-bath-mapping-${apiRootPath}`, {
|
|
152
156
|
basePath: apiRootPath,
|
|
153
157
|
domainName: this.restApiDomain,
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.RestApiLambdaWithCache = void 0;
|
|
4
7
|
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
5
8
|
const aws_ec2_1 = require("aws-cdk-lib/aws-ec2");
|
|
6
9
|
const aws_iam_1 = require("aws-cdk-lib/aws-iam");
|
|
10
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
7
11
|
const __1 = require("..");
|
|
8
12
|
const utils_1 = require("../../utils");
|
|
9
13
|
/**
|
|
@@ -77,7 +81,7 @@ class RestApiLambdaWithCache extends __1.RestApiLambda {
|
|
|
77
81
|
if (!this.props.restApiCache) {
|
|
78
82
|
return;
|
|
79
83
|
}
|
|
80
|
-
this.restApiCache = this.elasticacheManager.createReplicatedElastiCache(`${this.id}-elasticache`, this, this.props.restApiCache, this.restApivpc.privateSubnets
|
|
84
|
+
this.restApiCache = this.elasticacheManager.createReplicatedElastiCache(`${this.id}-elasticache`, this, this.props.restApiCache, lodash_1.default.map(this.restApivpc.privateSubnets, subnet => subnet.subnetId), [this.restApiSecurityGroup.securityGroupId]);
|
|
81
85
|
this.ssmManager.writeStringToParameters(`${this.id}-elasticache-endpoint-address`, this, {
|
|
82
86
|
description: `Elasticache address to use by applications`,
|
|
83
87
|
parameterName: `${this.id}-elasticache-endpoint-address`,
|
|
@@ -308,12 +308,14 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
|
|
|
308
308
|
},
|
|
309
309
|
name: `${this.id}-fs`,
|
|
310
310
|
});
|
|
311
|
-
if (this.props.siteTask.mountPoints && this.props.siteTask.mountPoints
|
|
312
|
-
this.props.siteTask.mountPoints
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
311
|
+
if (this.props.siteTask.mountPoints && !lodash_1.default.isEmpty(this.props.siteTask.mountPoints)) {
|
|
312
|
+
lodash_1.default.forEach(this.props.siteTask.mountPoints, mountPoint => {
|
|
313
|
+
this.siteEcsTaskDefinition.defaultContainer?.addMountPoints({
|
|
314
|
+
containerPath: mountPoint.containerPath,
|
|
315
|
+
readOnly: mountPoint.readOnly,
|
|
316
|
+
sourceVolume: `${this.id}-fs`,
|
|
317
|
+
});
|
|
318
|
+
});
|
|
317
319
|
}
|
|
318
320
|
}
|
|
319
321
|
this.addCfnOutput(`${this.id}-loadBalancerArn`, this.siteEcsLoadBalancer.loadBalancerArn ?? '');
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.StaticAssetDeployment = void 0;
|
|
4
7
|
const aws_s3_deployment_1 = require("aws-cdk-lib/aws-s3-deployment");
|
|
8
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
5
9
|
const common_1 = require("../../common");
|
|
6
10
|
/**
|
|
7
11
|
* @classdesc Provides a construct to create and deploy static assets into S3 bucket
|
|
@@ -55,7 +59,7 @@ class StaticAssetDeployment extends common_1.CommonConstruct {
|
|
|
55
59
|
if (!staticAssetsForExport)
|
|
56
60
|
return;
|
|
57
61
|
/* optional additional exports needed for asset urls */
|
|
58
|
-
|
|
62
|
+
lodash_1.default.forEach(staticAssetsForExport, asset => {
|
|
59
63
|
this.addCfnOutput(asset.key, this.staticAssetBucket.s3UrlForObject(asset.value));
|
|
60
64
|
});
|
|
61
65
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.ApiManager = void 0;
|
|
4
7
|
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
5
8
|
const aws_apigateway_1 = require("aws-cdk-lib/aws-apigateway");
|
|
9
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
6
10
|
const utils_1 = require("../../utils");
|
|
7
11
|
/**
|
|
8
12
|
* @classdesc Provides operations on AWS API Gateway.
|
|
@@ -70,8 +74,8 @@ class ApiManager {
|
|
|
70
74
|
restApiName: `${props.restApiName}-${scope.props.stage}`,
|
|
71
75
|
retainDeployments: props.retainDeployments,
|
|
72
76
|
});
|
|
73
|
-
if (props.tags && props.tags
|
|
74
|
-
|
|
77
|
+
if (props.tags && !lodash_1.default.isEmpty(props.tags)) {
|
|
78
|
+
lodash_1.default.forEach(props.tags, tag => {
|
|
75
79
|
aws_cdk_lib_1.Tags.of(api).add(tag.key, tag.value);
|
|
76
80
|
});
|
|
77
81
|
}
|
|
@@ -121,10 +125,12 @@ class ApiManager {
|
|
|
121
125
|
allowOrigins: allowedOrigins ?? aws_apigateway_1.Cors.ALL_ORIGINS,
|
|
122
126
|
},
|
|
123
127
|
});
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
+
lodash_1.default.forEach(methods, method => {
|
|
129
|
+
resource.addMethod(method, integration, {
|
|
130
|
+
authorizer,
|
|
131
|
+
requestParameters: methodRequestParameters,
|
|
132
|
+
});
|
|
133
|
+
});
|
|
128
134
|
(0, utils_1.createCfnOutput)(`${id}-${path}ResourceId`, scope, resource.resourceId);
|
|
129
135
|
if (addProxy) {
|
|
130
136
|
const resourceProxy = resource.addResource(`{${path}+}`, {
|
|
@@ -135,10 +141,12 @@ class ApiManager {
|
|
|
135
141
|
allowOrigins: allowedOrigins ?? aws_apigateway_1.Cors.ALL_ORIGINS,
|
|
136
142
|
},
|
|
137
143
|
});
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
144
|
+
lodash_1.default.forEach(methods, method => {
|
|
145
|
+
resourceProxy.addMethod(method, proxyIntegration ?? integration, {
|
|
146
|
+
authorizer,
|
|
147
|
+
requestParameters: methodRequestParameters,
|
|
148
|
+
});
|
|
149
|
+
});
|
|
142
150
|
(0, utils_1.createCfnOutput)(`${id}-${path}ProxyResourceId`, scope, resourceProxy.resourceId);
|
|
143
151
|
}
|
|
144
152
|
return resource;
|
|
@@ -22,6 +22,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
29
|
exports.CloudFrontManager = void 0;
|
|
27
30
|
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
@@ -31,6 +34,7 @@ const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
|
|
|
31
34
|
const custom_resources_1 = require("aws-cdk-lib/custom-resources");
|
|
32
35
|
const common_1 = require("../../common");
|
|
33
36
|
const utils_1 = require("../../utils");
|
|
37
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
34
38
|
/**
|
|
35
39
|
* @classdesc Provides operations on AWS
|
|
36
40
|
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
@@ -110,8 +114,8 @@ class CloudFrontManager {
|
|
|
110
114
|
}),
|
|
111
115
|
webACLId: props.webACLId,
|
|
112
116
|
});
|
|
113
|
-
if (props.tags && props.tags
|
|
114
|
-
|
|
117
|
+
if (props.tags && !lodash_1.default.isEmpty(props.tags)) {
|
|
118
|
+
lodash_1.default.forEach(props.tags, tag => {
|
|
115
119
|
aws_cdk_lib_1.Tags.of(distribution).add(tag.key, tag.value);
|
|
116
120
|
});
|
|
117
121
|
}
|
|
@@ -160,8 +164,8 @@ class CloudFrontManager {
|
|
|
160
164
|
priceClass: props.priceClass ?? aws_cloudfront_1.PriceClass.PRICE_CLASS_ALL,
|
|
161
165
|
webAclId: props.webAclId,
|
|
162
166
|
});
|
|
163
|
-
if (props.tags && props.tags
|
|
164
|
-
|
|
167
|
+
if (props.tags && !lodash_1.default.isEmpty(props.tags)) {
|
|
168
|
+
lodash_1.default.forEach(props.tags, tag => {
|
|
165
169
|
aws_cdk_lib_1.Tags.of(distribution).add(tag.key, tag.value);
|
|
166
170
|
});
|
|
167
171
|
}
|
|
@@ -210,8 +214,8 @@ class CloudFrontManager {
|
|
|
210
214
|
priceClass: props.priceClass ?? aws_cloudfront_1.PriceClass.PRICE_CLASS_ALL,
|
|
211
215
|
webAclId: props.webAclId,
|
|
212
216
|
});
|
|
213
|
-
if (props.tags && props.tags
|
|
214
|
-
|
|
217
|
+
if (props.tags && !lodash_1.default.isEmpty(props.tags)) {
|
|
218
|
+
lodash_1.default.forEach(props.tags, tag => {
|
|
215
219
|
aws_cdk_lib_1.Tags.of(distribution).add(tag.key, tag.value);
|
|
216
220
|
});
|
|
217
221
|
}
|
|
@@ -256,7 +260,7 @@ class CloudFrontManager {
|
|
|
256
260
|
timeout: props.timeoutInSecs ? aws_cdk_lib_1.Duration.seconds(props.timeoutInSecs) : aws_cdk_lib_1.Duration.minutes(1),
|
|
257
261
|
vpc: vpc,
|
|
258
262
|
});
|
|
259
|
-
if (props.tags && props.tags
|
|
263
|
+
if (props.tags && !lodash_1.default.isEmpty(props.tags)) {
|
|
260
264
|
props.tags.forEach(tag => {
|
|
261
265
|
aws_cdk_lib_1.Tags.of(edgeFunction).add(tag.key, tag.value);
|
|
262
266
|
});
|