quidproquo-deploy-awscdk 0.0.45 → 0.0.47
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/lib/QPQPrototypeSingleServiceStack.js +14 -8
- package/lib/lambdas/actionProcessorListResolver.d.ts +3 -3
- package/lib/lambdas/lambdaAPIGatewayEvent.d.ts +12 -2
- package/lib/lambdas/lambdaAPIGatewayEvent.js +9 -4
- package/lib/lambdas/lambdaConfig.d.ts +7 -2
- package/lib/lambdas/lambdaConfig.js +28 -2
- package/lib/lambdas/lambdaEventBridgeEvent.js +5 -1
- package/lib/lambdas/lambdaEventOriginRequest.d.ts +3 -13
- package/lib/lambdas/lambdaEventOriginRequest.js +13 -10
- package/lib/lambdas/lambdaEventViewerRequest.js +1 -0
- package/package.json +1 -1
- package/src/QPQPrototypeSingleServiceStack.ts +18 -13
- package/src/lambdas/actionProcessorListResolver.ts +4 -3
- package/src/lambdas/lambdaAPIGatewayEvent.ts +18 -10
- package/src/lambdas/lambdaConfig.ts +26 -4
- package/src/lambdas/lambdaEventBridgeEvent.ts +17 -6
- package/src/lambdas/lambdaEventOriginRequest.ts +26 -20
- package/src/lambdas/lambdaEventViewerRequest.ts +2 -0
|
@@ -29,6 +29,7 @@ const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
|
29
29
|
const cdk = __importStar(require("aws-cdk-lib"));
|
|
30
30
|
const quidproquo_core_1 = require("quidproquo-core");
|
|
31
31
|
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
32
|
+
const qpqResourceMapConfigName = 'qpq-aws-resource-map';
|
|
32
33
|
const grantReadToOwnedResources = (ownedResourceSettings, identity) => {
|
|
33
34
|
ownedResourceSettings.ownedBuckets.forEach((b) => b.bucket.grantReadWrite(identity));
|
|
34
35
|
ownedResourceSettings.ownedSecrets.forEach((os) => os.secret.grantRead(identity));
|
|
@@ -241,14 +242,13 @@ class QPQPrototypeSingleServiceStack extends aws_cdk_lib_1.Stack {
|
|
|
241
242
|
});
|
|
242
243
|
// This should be all resource names
|
|
243
244
|
const runtimeConfigLambdaConfig = {
|
|
244
|
-
qpqConfig: props.qpqConfig,
|
|
245
245
|
secretNameMap: ownedSecrets.reduce((acc, os) => (Object.assign(Object.assign({}, acc), { [os.secretName]: os.realName })), {}),
|
|
246
|
-
parameterNameMap: Object.assign(Object.assign({}, ownedParameters.reduce((acc, os) => (Object.assign(Object.assign({}, acc), { [os.parameterName]: os.realName })), {})), { [
|
|
246
|
+
parameterNameMap: Object.assign(Object.assign({}, ownedParameters.reduce((acc, os) => (Object.assign(Object.assign({}, acc), { [os.parameterName]: os.realName })), {})), { [qpqResourceMapConfigName]: getParameterName(qpqResourceMapConfigName, settings.service, settings.environment) }),
|
|
247
247
|
resourceNameMap: ownedBuckets.reduce((acc, b) => (Object.assign(Object.assign({}, acc), { [b.driveName]: b.bucketName })), {}),
|
|
248
248
|
};
|
|
249
249
|
// Build the param that stores the config
|
|
250
250
|
// Note: The mapping was done manually previously inside the value
|
|
251
|
-
ownedParameters.push(createServiceParameter(this, id, settings.service, settings.environment,
|
|
251
|
+
ownedParameters.push(createServiceParameter(this, id, settings.service, settings.environment, qpqResourceMapConfigName, JSON.stringify(runtimeConfigLambdaConfig)));
|
|
252
252
|
const ownedResourceSettings = {
|
|
253
253
|
ownedBuckets,
|
|
254
254
|
ownedParameters,
|
|
@@ -258,11 +258,17 @@ class QPQPrototypeSingleServiceStack extends aws_cdk_lib_1.Stack {
|
|
|
258
258
|
// Finished building resources, now we can build the lambdas
|
|
259
259
|
////////////////////////////////////////////////////////////////////////////////////
|
|
260
260
|
createWebDistribution(this, `${id}-web-dist`, props, ownedResourceSettings);
|
|
261
|
+
const BLLayer = new aws_cdk_lib_1.aws_lambda.LayerVersion(this, `${id}-some-layer`, {
|
|
262
|
+
layerVersionName: `${id}-some-layer`,
|
|
263
|
+
code: new aws_cdk_lib_1.aws_lambda.AssetCode(path.join(props.apiBuildPath, '../../layers')),
|
|
264
|
+
compatibleRuntimes: [aws_cdk_lib_1.aws_lambda.Runtime.NODEJS_16_X],
|
|
265
|
+
});
|
|
261
266
|
const lambdaHandler = new aws_cdk_lib_1.aws_lambda.Function(this, `${settings.environment}-${settings.service}-lambda-rest`, {
|
|
262
267
|
functionName: `lambda-rest-${settings.service}-${settings.environment}`,
|
|
263
268
|
timeout: cdk.Duration.seconds(25),
|
|
264
269
|
runtime: aws_cdk_lib_1.aws_lambda.Runtime.NODEJS_16_X,
|
|
265
270
|
memorySize: 1024,
|
|
271
|
+
layers: [BLLayer],
|
|
266
272
|
code: aws_cdk_lib_1.aws_lambda.Code.fromAsset(path.join(props.apiBuildPath, 'lambdaAPIGatewayEvent')),
|
|
267
273
|
handler: 'index.executeAPIGatewayEvent',
|
|
268
274
|
environment: {
|
|
@@ -280,6 +286,7 @@ class QPQPrototypeSingleServiceStack extends aws_cdk_lib_1.Stack {
|
|
|
280
286
|
loggingLevel: aws_cdk_lib_1.aws_apigateway.MethodLoggingLevel.INFO,
|
|
281
287
|
dataTraceEnabled: true,
|
|
282
288
|
},
|
|
289
|
+
binaryMediaTypes: ['*/*'],
|
|
283
290
|
proxy: true,
|
|
284
291
|
});
|
|
285
292
|
// Map all requests to this service to /serviceName/*
|
|
@@ -298,11 +305,10 @@ class QPQPrototypeSingleServiceStack extends aws_cdk_lib_1.Stack {
|
|
|
298
305
|
code: aws_cdk_lib_1.aws_lambda.Code.fromAsset(path.join(props.apiBuildPath, 'lambdaEventBridgeEvent')),
|
|
299
306
|
handler: 'index.executeEventBridgeEvent',
|
|
300
307
|
environment: {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
} })),
|
|
308
|
+
lambdaRuntimeConfig: JSON.stringify({
|
|
309
|
+
src: se.src,
|
|
310
|
+
runtime: se.runtime,
|
|
311
|
+
}),
|
|
306
312
|
},
|
|
307
313
|
});
|
|
308
314
|
grantReadToOwnedResources(ownedResourceSettings, schedulerFunction);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ActionProcessorList } from 'quidproquo-core';
|
|
2
|
-
import {
|
|
3
|
-
export type ActionProcessorListResolver = (
|
|
1
|
+
import { ActionProcessorList, QPQConfig } from 'quidproquo-core';
|
|
2
|
+
import { QPQAWSResourceMap } from 'quidproquo-actionprocessor-awslambda';
|
|
3
|
+
export type ActionProcessorListResolver = (qpqConfig: QPQConfig, awsResourceMap: QPQAWSResourceMap) => ActionProcessorList;
|
|
@@ -3,11 +3,21 @@ import { Context } from 'aws-lambda';
|
|
|
3
3
|
import { ActionProcessorListResolver } from './actionProcessorListResolver';
|
|
4
4
|
export declare const getAPIGatewayEventExecutor: (dynamicModuleLoader: DynamicModuleLoader, getCustomActionProcessors?: ActionProcessorListResolver) => (event: import("aws-lambda").APIGatewayProxyEvent, context: Context) => Promise<{
|
|
5
5
|
statusCode: any;
|
|
6
|
-
body:
|
|
6
|
+
body: any;
|
|
7
7
|
headers: any;
|
|
8
|
+
isBase64Encoded: any;
|
|
9
|
+
} | {
|
|
10
|
+
statusCode: number;
|
|
11
|
+
body: string;
|
|
12
|
+
headers: import("quidproquo-webserver").HttpEventHeaders;
|
|
8
13
|
}>;
|
|
9
14
|
export declare const executeAPIGatewayEvent: (event: import("aws-lambda").APIGatewayProxyEvent, context: Context) => Promise<{
|
|
10
15
|
statusCode: any;
|
|
11
|
-
body:
|
|
16
|
+
body: any;
|
|
12
17
|
headers: any;
|
|
18
|
+
isBase64Encoded: any;
|
|
19
|
+
} | {
|
|
20
|
+
statusCode: number;
|
|
21
|
+
body: string;
|
|
22
|
+
headers: import("quidproquo-webserver").HttpEventHeaders;
|
|
13
23
|
}>;
|
|
@@ -20,6 +20,8 @@ const quidproquo_core_1 = require("quidproquo-core");
|
|
|
20
20
|
const lambdaConfig_1 = require("./lambdaConfig");
|
|
21
21
|
// @ts-ignore - Special webpack loader
|
|
22
22
|
const qpq_dynamic_loader_1 = __importDefault(require("qpq-dynamic-loader!"));
|
|
23
|
+
// @ts-ignore - Special webpack loader
|
|
24
|
+
const qpq_custom_action_processors_loader_1 = __importDefault(require("qpq-custom-action-processors-loader!"));
|
|
23
25
|
// TODO: Make this a util or something based on server time or something..
|
|
24
26
|
const getDateNow = () => new Date().toISOString();
|
|
25
27
|
const ErrorTypeHttpResponseMap = {
|
|
@@ -38,9 +40,10 @@ const ErrorTypeHttpResponseMap = {
|
|
|
38
40
|
};
|
|
39
41
|
const getAPIGatewayEventExecutor = (dynamicModuleLoader, getCustomActionProcessors = () => ({})) => {
|
|
40
42
|
return (event, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
+
const cdkConfig = yield (0, lambdaConfig_1.getLambdaConfigs)();
|
|
41
44
|
// Build a processor for the session and stuff
|
|
42
45
|
// Remove the non route ones ~ let the story execute action add them
|
|
43
|
-
const storyActionProcessor = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, quidproquo_actionprocessor_node_1.coreActionProcessor), quidproquo_actionprocessor_node_1.webserverActionProcessor), (0, quidproquo_actionprocessor_awslambda_1.getAPIGatewayEventActionProcessor)(
|
|
46
|
+
const storyActionProcessor = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, quidproquo_actionprocessor_node_1.coreActionProcessor), quidproquo_actionprocessor_node_1.webserverActionProcessor), (0, quidproquo_actionprocessor_awslambda_1.getAPIGatewayEventActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetSecretActionProcessor)(cdkConfig.qpqConfig, cdkConfig.awsResourceMap)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParameterActionProcessor)(cdkConfig.qpqConfig, cdkConfig.awsResourceMap)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParametersActionProcessor)(cdkConfig.qpqConfig, cdkConfig.awsResourceMap)), (0, quidproquo_actionprocessor_awslambda_1.getSystemActionProcessor)(dynamicModuleLoader)), (0, quidproquo_actionprocessor_awslambda_1.getFileActionProcessor)(cdkConfig.qpqConfig, cdkConfig.awsResourceMap)), getCustomActionProcessors(cdkConfig.qpqConfig, cdkConfig.awsResourceMap)), (0, qpq_custom_action_processors_loader_1.default)());
|
|
44
47
|
const logger = (result) => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
48
|
// addResult(
|
|
46
49
|
// envConfig.appName,
|
|
@@ -57,17 +60,19 @@ const getAPIGatewayEventExecutor = (dynamicModuleLoader, getCustomActionProcesso
|
|
|
57
60
|
const result = yield resolveStory(quidproquo_core_1.askProcessEvent, [event, context]);
|
|
58
61
|
// Run the callback
|
|
59
62
|
if (!result.error) {
|
|
60
|
-
|
|
63
|
+
const response = {
|
|
61
64
|
statusCode: result.result.statusCode,
|
|
62
|
-
body:
|
|
65
|
+
body: result.result.body,
|
|
63
66
|
headers: result.result.headers,
|
|
67
|
+
isBase64Encoded: result.result.isBase64Encoded,
|
|
64
68
|
};
|
|
69
|
+
return response;
|
|
65
70
|
}
|
|
66
71
|
const code = ErrorTypeHttpResponseMap[result.error.errorType];
|
|
67
72
|
return {
|
|
68
73
|
statusCode: code || 500,
|
|
69
74
|
body: JSON.stringify(result.error),
|
|
70
|
-
headers: quidproquo_webserver_1.qpqWebServerUtils.getCorsHeaders(
|
|
75
|
+
headers: quidproquo_webserver_1.qpqWebServerUtils.getCorsHeaders(cdkConfig.qpqConfig, {}, event.headers),
|
|
71
76
|
};
|
|
72
77
|
});
|
|
73
78
|
};
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { QPQConfig } from 'quidproquo-core';
|
|
2
|
+
import { QPQAWSResourceMap } from 'quidproquo-actionprocessor-awslambda';
|
|
3
|
+
export interface QPQCDKConfig {
|
|
4
|
+
awsResourceMap: QPQAWSResourceMap;
|
|
5
|
+
qpqConfig: QPQConfig;
|
|
6
|
+
}
|
|
7
|
+
export declare const getLambdaConfigs: () => Promise<QPQCDKConfig>;
|
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
2
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
15
|
+
exports.getLambdaConfigs = void 0;
|
|
16
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
17
|
+
const quidproquo_actionprocessor_awslambda_1 = require("quidproquo-actionprocessor-awslambda");
|
|
18
|
+
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
const qpq_config_loader_1 = __importDefault(require("qpq-config-loader!"));
|
|
21
|
+
const getLambdaConfigs = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
const service = quidproquo_core_1.qpqCoreUtils.getAppName(qpq_config_loader_1.default);
|
|
23
|
+
const environment = quidproquo_core_1.qpqCoreUtils.getAppFeature(qpq_config_loader_1.default);
|
|
24
|
+
const param = yield (0, quidproquo_actionprocessor_awslambda_1.getParameter)(`qpq-aws-resource-map-${service}-${environment}`, quidproquo_webserver_1.qpqWebServerUtils.getDeployRegion(qpq_config_loader_1.default));
|
|
25
|
+
return {
|
|
26
|
+
awsResourceMap: JSON.parse(param),
|
|
27
|
+
qpqConfig: qpq_config_loader_1.default,
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
exports.getLambdaConfigs = getLambdaConfigs;
|
|
@@ -19,13 +19,17 @@ const quidproquo_core_1 = require("quidproquo-core");
|
|
|
19
19
|
const lambdaConfig_1 = require("./lambdaConfig");
|
|
20
20
|
// @ts-ignore - Special webpack loader
|
|
21
21
|
const qpq_dynamic_loader_1 = __importDefault(require("qpq-dynamic-loader!"));
|
|
22
|
+
// @ts-ignore - Special webpack loader
|
|
23
|
+
const qpq_custom_action_processors_loader_1 = __importDefault(require("qpq-custom-action-processors-loader!"));
|
|
22
24
|
// TODO: Make this a util or something based on server time or something..
|
|
23
25
|
const getDateNow = () => new Date().toISOString();
|
|
24
26
|
const getEventBridgeEventExecutor = (dynamicModuleLoader, getCustomActionProcessors = () => ({})) => {
|
|
25
27
|
return (event, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
const cdkConfig = yield (0, lambdaConfig_1.getLambdaConfigs)();
|
|
29
|
+
const lambdaRuntimeConfig = JSON.parse(process.env.lambdaRuntimeConfig || '{}');
|
|
26
30
|
// Build a processor for the session and stuff
|
|
27
31
|
// Remove the non event ones
|
|
28
|
-
const storyActionProcessor = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, quidproquo_actionprocessor_node_1.coreActionProcessor), quidproquo_actionprocessor_node_1.webserverActionProcessor), (0, quidproquo_actionprocessor_awslambda_1.getEventBridgeEventActionProcessor)(
|
|
32
|
+
const storyActionProcessor = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, quidproquo_actionprocessor_node_1.coreActionProcessor), quidproquo_actionprocessor_node_1.webserverActionProcessor), (0, quidproquo_actionprocessor_awslambda_1.getEventBridgeEventActionProcessor)(lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getSystemActionProcessor)(dynamicModuleLoader)), (0, quidproquo_actionprocessor_awslambda_1.getFileActionProcessor)(cdkConfig.qpqConfig, cdkConfig.awsResourceMap)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetSecretActionProcessor)(cdkConfig.qpqConfig, cdkConfig.awsResourceMap)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParameterActionProcessor)(cdkConfig.qpqConfig, cdkConfig.awsResourceMap)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParametersActionProcessor)(cdkConfig.qpqConfig, cdkConfig.awsResourceMap)), getCustomActionProcessors(cdkConfig.qpqConfig, cdkConfig.awsResourceMap)), (0, qpq_custom_action_processors_loader_1.default)());
|
|
29
33
|
const logger = (result) => __awaiter(void 0, void 0, void 0, function* () { });
|
|
30
34
|
// Run the callback
|
|
31
35
|
const resolveStory = (0, quidproquo_core_1.createRuntime)({}, storyActionProcessor, getDateNow, logger, quidproquo_actionprocessor_awslambda_1.awsLambdaUtils.randomGuid);
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import { DynamicModuleLoader } from 'quidproquo-actionprocessor-awslambda';
|
|
2
|
-
import { CloudFrontRequestEvent, Context } from 'aws-lambda';
|
|
2
|
+
import { CloudFrontRequestEvent, CloudFrontRequestResult, Context } from 'aws-lambda';
|
|
3
3
|
import { ActionProcessorListResolver } from './actionProcessorListResolver';
|
|
4
|
-
export declare const getOriginRequestEventExecutor: (dynamicModuleLoader: DynamicModuleLoader, getCustomActionProcessors?: ActionProcessorListResolver) => (event: CloudFrontRequestEvent, context: Context) => Promise<
|
|
5
|
-
|
|
6
|
-
statusDescription: string;
|
|
7
|
-
body: any;
|
|
8
|
-
headers: {};
|
|
9
|
-
}>;
|
|
10
|
-
export declare const executeEventOriginRequest: (event: CloudFrontRequestEvent, context: Context) => Promise<import("aws-lambda").CloudFrontRequest | {
|
|
11
|
-
status: string;
|
|
12
|
-
statusDescription: string;
|
|
13
|
-
body: any;
|
|
14
|
-
headers: {};
|
|
15
|
-
}>;
|
|
4
|
+
export declare const getOriginRequestEventExecutor: (dynamicModuleLoader: DynamicModuleLoader, getCustomActionProcessors?: ActionProcessorListResolver) => (event: CloudFrontRequestEvent, context: Context) => Promise<CloudFrontRequestResult>;
|
|
5
|
+
export declare const executeEventOriginRequest: (event: CloudFrontRequestEvent, context: Context) => Promise<CloudFrontRequestResult>;
|
|
@@ -15,29 +15,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.executeEventOriginRequest = exports.getOriginRequestEventExecutor = void 0;
|
|
16
16
|
const quidproquo_actionprocessor_node_1 = require("quidproquo-actionprocessor-node");
|
|
17
17
|
const quidproquo_actionprocessor_awslambda_1 = require("quidproquo-actionprocessor-awslambda");
|
|
18
|
-
const
|
|
18
|
+
const lambdaConfig_1 = require("./lambdaConfig");
|
|
19
19
|
const quidproquo_core_1 = require("quidproquo-core");
|
|
20
20
|
// @ts-ignore - Special webpack loader
|
|
21
21
|
const qpq_dynamic_loader_1 = __importDefault(require("qpq-dynamic-loader!"));
|
|
22
22
|
// @ts-ignore - Special webpack loader
|
|
23
|
-
const
|
|
23
|
+
const qpq_custom_action_processors_loader_1 = __importDefault(require("qpq-custom-action-processors-loader!"));
|
|
24
24
|
// TODO: Make this a util or something based on server time or something..
|
|
25
25
|
const getDateNow = () => new Date().toISOString();
|
|
26
26
|
const getOriginRequestEventExecutor = (dynamicModuleLoader, getCustomActionProcessors = () => ({})) => {
|
|
27
27
|
return (event, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
console.log(JSON.stringify(event));
|
|
28
29
|
// Don't run the lambda if we are not a bot
|
|
29
|
-
if (event.Records[0].cf.request.headers['x-qpq-is-bot']
|
|
30
|
+
if (!event.Records[0].cf.request.headers['x-qpq-is-bot'] ||
|
|
31
|
+
event.Records[0].cf.request.headers['x-qpq-is-bot'][0].value !== 'true') {
|
|
30
32
|
return event.Records[0].cf.request;
|
|
31
33
|
}
|
|
32
|
-
|
|
33
|
-
const service = quidproquo_core_1.qpqCoreUtils.getAppName(qpq_config_loader_1.default);
|
|
34
|
-
const environment = quidproquo_core_1.qpqCoreUtils.getAppFeature(qpq_config_loader_1.default);
|
|
35
|
-
const param = yield (0, quidproquo_actionprocessor_awslambda_1.getParameter)(`qpqRuntimeConfig-${service}-${environment}`, quidproquo_webserver_1.qpqWebServerUtils.getDeployRegion(qpq_config_loader_1.default));
|
|
36
|
-
const lambdaRuntimeConfig = JSON.parse(param);
|
|
37
|
-
// //////////////////////////
|
|
34
|
+
const cdkConfig = yield (0, lambdaConfig_1.getLambdaConfigs)();
|
|
38
35
|
// Build a processor for the session and stuff
|
|
39
36
|
// Remove the non route ones ~ let the story execute action add them
|
|
40
|
-
const storyActionProcessor = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, quidproquo_actionprocessor_node_1.coreActionProcessor), quidproquo_actionprocessor_node_1.webserverActionProcessor), (0, quidproquo_actionprocessor_awslambda_1.getCloudFrontOriginRequestEventActionProcessor)(
|
|
37
|
+
const storyActionProcessor = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, quidproquo_actionprocessor_node_1.coreActionProcessor), quidproquo_actionprocessor_node_1.webserverActionProcessor), (0, quidproquo_actionprocessor_awslambda_1.getCloudFrontOriginRequestEventActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetSecretActionProcessor)(cdkConfig.qpqConfig, cdkConfig.awsResourceMap)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParameterActionProcessor)(cdkConfig.qpqConfig, cdkConfig.awsResourceMap)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParametersActionProcessor)(cdkConfig.qpqConfig, cdkConfig.awsResourceMap)), (0, quidproquo_actionprocessor_awslambda_1.getSystemActionProcessor)(dynamicModuleLoader)), (0, quidproquo_actionprocessor_awslambda_1.getFileActionProcessor)(cdkConfig.qpqConfig, cdkConfig.awsResourceMap)), getCustomActionProcessors(cdkConfig.qpqConfig, cdkConfig.awsResourceMap)), (0, qpq_custom_action_processors_loader_1.default)());
|
|
41
38
|
const logger = (result) => __awaiter(void 0, void 0, void 0, function* () { });
|
|
42
39
|
// Run the callback
|
|
43
40
|
const resolveStory = (0, quidproquo_core_1.createRuntime)({}, storyActionProcessor, getDateNow, logger, quidproquo_actionprocessor_awslambda_1.awsLambdaUtils.randomGuid);
|
|
@@ -57,10 +54,16 @@ const getOriginRequestEventExecutor = (dynamicModuleLoader, getCustomActionProce
|
|
|
57
54
|
statusDescription: 'OK',
|
|
58
55
|
body: result.result.body,
|
|
59
56
|
headers: responseHeaders,
|
|
57
|
+
bodyEncoding: result.result.bodyEncoding,
|
|
60
58
|
};
|
|
61
59
|
}
|
|
62
60
|
// CloudFront seems to throw an error when you send back a 404 or something, so we will just hit the normal origin
|
|
63
61
|
return event.Records[0].cf.request;
|
|
62
|
+
/*return {
|
|
63
|
+
status: `200`,
|
|
64
|
+
statusDescription: 'OK',
|
|
65
|
+
body: `<pre>${JSON.stringify(result.error, null, 2)}</pre>`,
|
|
66
|
+
} as CloudFrontRequestResult;*/
|
|
64
67
|
// const code = ErrorTypeHttpResponseMap[result.error.errorType];
|
|
65
68
|
// return {
|
|
66
69
|
// statusCode: code || 500,
|
|
@@ -13,6 +13,7 @@ exports.executeEventViewerRequest = exports.getViewerRequestEventExecutor = void
|
|
|
13
13
|
const getViewerRequestEventExecutor = () => {
|
|
14
14
|
return (event, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
15
|
var _a;
|
|
16
|
+
console.log(JSON.stringify(event));
|
|
16
17
|
const request = event.Records[0].cf.request;
|
|
17
18
|
const headers = request.headers;
|
|
18
19
|
const customUserAgentHeaderName = 'x-qpq-is-bot';
|
package/package.json
CHANGED
|
@@ -21,11 +21,13 @@ import * as cdk from 'aws-cdk-lib';
|
|
|
21
21
|
|
|
22
22
|
import { Construct } from 'constructs';
|
|
23
23
|
|
|
24
|
-
import {
|
|
24
|
+
import { QPQAWSResourceMap, LambdaRuntimeConfig } from 'quidproquo-actionprocessor-awslambda';
|
|
25
25
|
|
|
26
26
|
import { qpqCoreUtils } from 'quidproquo-core';
|
|
27
27
|
import { qpqWebServerUtils } from 'quidproquo-webserver';
|
|
28
28
|
|
|
29
|
+
const qpqResourceMapConfigName = 'qpq-aws-resource-map';
|
|
30
|
+
|
|
29
31
|
export interface QPQPrototypeStackProps extends DeploymentSettings {
|
|
30
32
|
account: string;
|
|
31
33
|
|
|
@@ -360,8 +362,7 @@ export class QPQPrototypeSingleServiceStack extends Stack {
|
|
|
360
362
|
});
|
|
361
363
|
|
|
362
364
|
// This should be all resource names
|
|
363
|
-
const runtimeConfigLambdaConfig:
|
|
364
|
-
qpqConfig: props.qpqConfig,
|
|
365
|
+
const runtimeConfigLambdaConfig: QPQAWSResourceMap = {
|
|
365
366
|
secretNameMap: ownedSecrets.reduce(
|
|
366
367
|
(acc, os) => ({
|
|
367
368
|
...acc,
|
|
@@ -377,8 +378,8 @@ export class QPQPrototypeSingleServiceStack extends Stack {
|
|
|
377
378
|
}),
|
|
378
379
|
{},
|
|
379
380
|
),
|
|
380
|
-
[
|
|
381
|
-
|
|
381
|
+
[qpqResourceMapConfigName]: getParameterName(
|
|
382
|
+
qpqResourceMapConfigName,
|
|
382
383
|
settings.service,
|
|
383
384
|
settings.environment,
|
|
384
385
|
),
|
|
@@ -400,7 +401,7 @@ export class QPQPrototypeSingleServiceStack extends Stack {
|
|
|
400
401
|
id,
|
|
401
402
|
settings.service,
|
|
402
403
|
settings.environment,
|
|
403
|
-
|
|
404
|
+
qpqResourceMapConfigName,
|
|
404
405
|
JSON.stringify(runtimeConfigLambdaConfig),
|
|
405
406
|
),
|
|
406
407
|
);
|
|
@@ -417,6 +418,12 @@ export class QPQPrototypeSingleServiceStack extends Stack {
|
|
|
417
418
|
|
|
418
419
|
createWebDistribution(this, `${id}-web-dist`, props, ownedResourceSettings);
|
|
419
420
|
|
|
421
|
+
const BLLayer = new aws_lambda.LayerVersion(this, `${id}-some-layer`, {
|
|
422
|
+
layerVersionName: `${id}-some-layer`,
|
|
423
|
+
code: new aws_lambda.AssetCode(path.join(props.apiBuildPath, '../../layers')),
|
|
424
|
+
compatibleRuntimes: [aws_lambda.Runtime.NODEJS_16_X],
|
|
425
|
+
});
|
|
426
|
+
|
|
420
427
|
const lambdaHandler = new aws_lambda.Function(
|
|
421
428
|
this,
|
|
422
429
|
`${settings.environment}-${settings.service}-lambda-rest`,
|
|
@@ -426,6 +433,7 @@ export class QPQPrototypeSingleServiceStack extends Stack {
|
|
|
426
433
|
|
|
427
434
|
runtime: aws_lambda.Runtime.NODEJS_16_X,
|
|
428
435
|
memorySize: 1024,
|
|
436
|
+
layers: [BLLayer],
|
|
429
437
|
|
|
430
438
|
code: aws_lambda.Code.fromAsset(path.join(props.apiBuildPath, 'lambdaAPIGatewayEvent')),
|
|
431
439
|
handler: 'index.executeAPIGatewayEvent',
|
|
@@ -451,6 +459,7 @@ export class QPQPrototypeSingleServiceStack extends Stack {
|
|
|
451
459
|
loggingLevel: aws_apigateway.MethodLoggingLevel.INFO,
|
|
452
460
|
dataTraceEnabled: true,
|
|
453
461
|
},
|
|
462
|
+
binaryMediaTypes: ['*/*'],
|
|
454
463
|
proxy: true,
|
|
455
464
|
},
|
|
456
465
|
);
|
|
@@ -479,14 +488,10 @@ export class QPQPrototypeSingleServiceStack extends Stack {
|
|
|
479
488
|
handler: 'index.executeEventBridgeEvent',
|
|
480
489
|
|
|
481
490
|
environment: {
|
|
482
|
-
TABLES: JSON.stringify([]),
|
|
483
491
|
lambdaRuntimeConfig: JSON.stringify({
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
runtime: se.runtime,
|
|
488
|
-
},
|
|
489
|
-
}),
|
|
492
|
+
src: se.src,
|
|
493
|
+
runtime: se.runtime,
|
|
494
|
+
} as LambdaRuntimeConfig),
|
|
490
495
|
},
|
|
491
496
|
},
|
|
492
497
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ActionProcessorList } from 'quidproquo-core';
|
|
2
|
-
import {
|
|
1
|
+
import { ActionProcessorList, QPQConfig } from 'quidproquo-core';
|
|
2
|
+
import { QPQAWSResourceMap } from 'quidproquo-actionprocessor-awslambda';
|
|
3
3
|
|
|
4
4
|
export type ActionProcessorListResolver = (
|
|
5
|
-
|
|
5
|
+
qpqConfig: QPQConfig,
|
|
6
|
+
awsResourceMap: QPQAWSResourceMap,
|
|
6
7
|
) => ActionProcessorList;
|
|
@@ -17,12 +17,15 @@ import { createRuntime, askProcessEvent, ErrorTypeEnum } from 'quidproquo-core';
|
|
|
17
17
|
|
|
18
18
|
import { APIGatewayEvent, Context } from 'aws-lambda';
|
|
19
19
|
|
|
20
|
-
import {
|
|
20
|
+
import { getLambdaConfigs } from './lambdaConfig';
|
|
21
21
|
import { ActionProcessorListResolver } from './actionProcessorListResolver';
|
|
22
22
|
|
|
23
23
|
// @ts-ignore - Special webpack loader
|
|
24
24
|
import qpqDynamicModuleLoader from 'qpq-dynamic-loader!';
|
|
25
25
|
|
|
26
|
+
// @ts-ignore - Special webpack loader
|
|
27
|
+
import qpqCustomActionProcessors from 'qpq-custom-action-processors-loader!';
|
|
28
|
+
|
|
26
29
|
// TODO: Make this a util or something based on server time or something..
|
|
27
30
|
const getDateNow = () => new Date().toISOString();
|
|
28
31
|
|
|
@@ -46,20 +49,23 @@ export const getAPIGatewayEventExecutor = (
|
|
|
46
49
|
getCustomActionProcessors: ActionProcessorListResolver = () => ({}),
|
|
47
50
|
) => {
|
|
48
51
|
return async (event: APIGatewayEvent, context: Context) => {
|
|
52
|
+
const cdkConfig = await getLambdaConfigs();
|
|
53
|
+
|
|
49
54
|
// Build a processor for the session and stuff
|
|
50
55
|
// Remove the non route ones ~ let the story execute action add them
|
|
51
56
|
const storyActionProcessor = {
|
|
52
57
|
...coreActionProcessor,
|
|
53
58
|
...webserverActionProcessor,
|
|
54
59
|
|
|
55
|
-
...getAPIGatewayEventActionProcessor(
|
|
56
|
-
...getConfigGetSecretActionProcessor(
|
|
57
|
-
...getConfigGetParameterActionProcessor(
|
|
58
|
-
...getConfigGetParametersActionProcessor(
|
|
60
|
+
...getAPIGatewayEventActionProcessor(cdkConfig.qpqConfig),
|
|
61
|
+
...getConfigGetSecretActionProcessor(cdkConfig.qpqConfig, cdkConfig.awsResourceMap),
|
|
62
|
+
...getConfigGetParameterActionProcessor(cdkConfig.qpqConfig, cdkConfig.awsResourceMap),
|
|
63
|
+
...getConfigGetParametersActionProcessor(cdkConfig.qpqConfig, cdkConfig.awsResourceMap),
|
|
59
64
|
...getSystemActionProcessor(dynamicModuleLoader),
|
|
60
|
-
...getFileActionProcessor(
|
|
65
|
+
...getFileActionProcessor(cdkConfig.qpqConfig, cdkConfig.awsResourceMap),
|
|
61
66
|
|
|
62
|
-
...getCustomActionProcessors(
|
|
67
|
+
...getCustomActionProcessors(cdkConfig.qpqConfig, cdkConfig.awsResourceMap),
|
|
68
|
+
...qpqCustomActionProcessors(),
|
|
63
69
|
};
|
|
64
70
|
|
|
65
71
|
const logger = async (result: any) => {
|
|
@@ -88,18 +94,20 @@ export const getAPIGatewayEventExecutor = (
|
|
|
88
94
|
|
|
89
95
|
// Run the callback
|
|
90
96
|
if (!result.error) {
|
|
91
|
-
|
|
97
|
+
const response = {
|
|
92
98
|
statusCode: result.result.statusCode,
|
|
93
|
-
body:
|
|
99
|
+
body: result.result.body,
|
|
94
100
|
headers: result.result.headers,
|
|
101
|
+
isBase64Encoded: result.result.isBase64Encoded,
|
|
95
102
|
};
|
|
103
|
+
return response;
|
|
96
104
|
}
|
|
97
105
|
|
|
98
106
|
const code = ErrorTypeHttpResponseMap[result.error.errorType];
|
|
99
107
|
return {
|
|
100
108
|
statusCode: code || 500,
|
|
101
109
|
body: JSON.stringify(result.error),
|
|
102
|
-
headers: qpqWebServerUtils.getCorsHeaders(
|
|
110
|
+
headers: qpqWebServerUtils.getCorsHeaders(cdkConfig.qpqConfig, {}, event.headers),
|
|
103
111
|
};
|
|
104
112
|
};
|
|
105
113
|
};
|
|
@@ -1,5 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { qpqCoreUtils, QPQConfig } from 'quidproquo-core';
|
|
2
|
+
import { QPQAWSResourceMap, getParameter } from 'quidproquo-actionprocessor-awslambda';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import { qpqWebServerUtils } from 'quidproquo-webserver';
|
|
5
|
+
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
import qpqConfig from 'qpq-config-loader!';
|
|
8
|
+
|
|
9
|
+
export interface QPQCDKConfig {
|
|
10
|
+
awsResourceMap: QPQAWSResourceMap;
|
|
11
|
+
qpqConfig: QPQConfig;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const getLambdaConfigs = async (): Promise<QPQCDKConfig> => {
|
|
15
|
+
const service = qpqCoreUtils.getAppName(qpqConfig);
|
|
16
|
+
const environment = qpqCoreUtils.getAppFeature(qpqConfig);
|
|
17
|
+
|
|
18
|
+
const param = await getParameter(
|
|
19
|
+
`qpq-aws-resource-map-${service}-${environment}`,
|
|
20
|
+
qpqWebServerUtils.getDeployRegion(qpqConfig),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
awsResourceMap: JSON.parse(param),
|
|
25
|
+
qpqConfig: qpqConfig,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
@@ -9,17 +9,21 @@ import {
|
|
|
9
9
|
getConfigGetParametersActionProcessor,
|
|
10
10
|
awsLambdaUtils,
|
|
11
11
|
DynamicModuleLoader,
|
|
12
|
+
LambdaRuntimeConfig,
|
|
12
13
|
} from 'quidproquo-actionprocessor-awslambda';
|
|
13
14
|
import { createRuntime, askProcessEvent } from 'quidproquo-core';
|
|
14
15
|
|
|
15
16
|
import { EventBridgeEvent, Context } from 'aws-lambda';
|
|
16
17
|
|
|
17
|
-
import {
|
|
18
|
+
import { getLambdaConfigs } from './lambdaConfig';
|
|
18
19
|
import { ActionProcessorListResolver } from './actionProcessorListResolver';
|
|
19
20
|
|
|
20
21
|
// @ts-ignore - Special webpack loader
|
|
21
22
|
import qpqDynamicModuleLoader from 'qpq-dynamic-loader!';
|
|
22
23
|
|
|
24
|
+
// @ts-ignore - Special webpack loader
|
|
25
|
+
import qpqCustomActionProcessors from 'qpq-custom-action-processors-loader!';
|
|
26
|
+
|
|
23
27
|
// TODO: Make this a util or something based on server time or something..
|
|
24
28
|
const getDateNow = () => new Date().toISOString();
|
|
25
29
|
|
|
@@ -28,6 +32,12 @@ export const getEventBridgeEventExecutor = (
|
|
|
28
32
|
getCustomActionProcessors: ActionProcessorListResolver = () => ({}),
|
|
29
33
|
) => {
|
|
30
34
|
return async (event: EventBridgeEvent<string, void>, context: Context) => {
|
|
35
|
+
const cdkConfig = await getLambdaConfigs();
|
|
36
|
+
|
|
37
|
+
const lambdaRuntimeConfig: LambdaRuntimeConfig = JSON.parse(
|
|
38
|
+
process.env.lambdaRuntimeConfig || '{}',
|
|
39
|
+
);
|
|
40
|
+
|
|
31
41
|
// Build a processor for the session and stuff
|
|
32
42
|
// Remove the non event ones
|
|
33
43
|
const storyActionProcessor = {
|
|
@@ -36,12 +46,13 @@ export const getEventBridgeEventExecutor = (
|
|
|
36
46
|
|
|
37
47
|
...getEventBridgeEventActionProcessor(lambdaRuntimeConfig),
|
|
38
48
|
...getSystemActionProcessor(dynamicModuleLoader),
|
|
39
|
-
...getFileActionProcessor(
|
|
40
|
-
...getConfigGetSecretActionProcessor(
|
|
41
|
-
...getConfigGetParameterActionProcessor(
|
|
42
|
-
...getConfigGetParametersActionProcessor(
|
|
49
|
+
...getFileActionProcessor(cdkConfig.qpqConfig, cdkConfig.awsResourceMap),
|
|
50
|
+
...getConfigGetSecretActionProcessor(cdkConfig.qpqConfig, cdkConfig.awsResourceMap),
|
|
51
|
+
...getConfigGetParameterActionProcessor(cdkConfig.qpqConfig, cdkConfig.awsResourceMap),
|
|
52
|
+
...getConfigGetParametersActionProcessor(cdkConfig.qpqConfig, cdkConfig.awsResourceMap),
|
|
43
53
|
|
|
44
|
-
...getCustomActionProcessors(
|
|
54
|
+
...getCustomActionProcessors(cdkConfig.qpqConfig, cdkConfig.awsResourceMap),
|
|
55
|
+
...qpqCustomActionProcessors(),
|
|
45
56
|
};
|
|
46
57
|
|
|
47
58
|
const logger = async (result: any) => {};
|
|
@@ -8,16 +8,17 @@ import {
|
|
|
8
8
|
getConfigGetParameterActionProcessor,
|
|
9
9
|
getConfigGetParametersActionProcessor,
|
|
10
10
|
awsLambdaUtils,
|
|
11
|
-
QPQAWSLambdaConfig,
|
|
12
11
|
DynamicModuleLoader,
|
|
13
12
|
getParameter,
|
|
14
13
|
} from 'quidproquo-actionprocessor-awslambda';
|
|
15
14
|
|
|
16
15
|
import { qpqWebServerUtils } from 'quidproquo-webserver';
|
|
17
16
|
|
|
17
|
+
import { getLambdaConfigs } from './lambdaConfig';
|
|
18
|
+
|
|
18
19
|
import { createRuntime, askProcessEvent, ErrorTypeEnum, qpqCoreUtils } from 'quidproquo-core';
|
|
19
20
|
|
|
20
|
-
import { CloudFrontRequestEvent, Context } from 'aws-lambda';
|
|
21
|
+
import { CloudFrontRequestEvent, CloudFrontRequestResult, Context } from 'aws-lambda';
|
|
21
22
|
|
|
22
23
|
import { ActionProcessorListResolver } from './actionProcessorListResolver';
|
|
23
24
|
|
|
@@ -25,7 +26,7 @@ import { ActionProcessorListResolver } from './actionProcessorListResolver';
|
|
|
25
26
|
import qpqDynamicModuleLoader from 'qpq-dynamic-loader!';
|
|
26
27
|
|
|
27
28
|
// @ts-ignore - Special webpack loader
|
|
28
|
-
import
|
|
29
|
+
import qpqCustomActionProcessors from 'qpq-custom-action-processors-loader!';
|
|
29
30
|
|
|
30
31
|
// TODO: Make this a util or something based on server time or something..
|
|
31
32
|
const getDateNow = () => new Date().toISOString();
|
|
@@ -35,20 +36,17 @@ export const getOriginRequestEventExecutor = (
|
|
|
35
36
|
getCustomActionProcessors: ActionProcessorListResolver = () => ({}),
|
|
36
37
|
) => {
|
|
37
38
|
return async (event: CloudFrontRequestEvent, context: Context) => {
|
|
39
|
+
console.log(JSON.stringify(event));
|
|
40
|
+
|
|
38
41
|
// Don't run the lambda if we are not a bot
|
|
39
|
-
if (
|
|
42
|
+
if (
|
|
43
|
+
!event.Records[0].cf.request.headers['x-qpq-is-bot'] ||
|
|
44
|
+
event.Records[0].cf.request.headers['x-qpq-is-bot'][0].value !== 'true'
|
|
45
|
+
) {
|
|
40
46
|
return event.Records[0].cf.request;
|
|
41
47
|
}
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
const service = qpqCoreUtils.getAppName(qpqConfig);
|
|
45
|
-
const environment = qpqCoreUtils.getAppFeature(qpqConfig);
|
|
46
|
-
const param = await getParameter(
|
|
47
|
-
`qpqRuntimeConfig-${service}-${environment}`,
|
|
48
|
-
qpqWebServerUtils.getDeployRegion(qpqConfig),
|
|
49
|
-
);
|
|
50
|
-
const lambdaRuntimeConfig: QPQAWSLambdaConfig = JSON.parse(param);
|
|
51
|
-
// //////////////////////////
|
|
49
|
+
const cdkConfig = await getLambdaConfigs();
|
|
52
50
|
|
|
53
51
|
// Build a processor for the session and stuff
|
|
54
52
|
// Remove the non route ones ~ let the story execute action add them
|
|
@@ -56,14 +54,15 @@ export const getOriginRequestEventExecutor = (
|
|
|
56
54
|
...coreActionProcessor,
|
|
57
55
|
...webserverActionProcessor,
|
|
58
56
|
|
|
59
|
-
...getCloudFrontOriginRequestEventActionProcessor(
|
|
60
|
-
...getConfigGetSecretActionProcessor(
|
|
61
|
-
...getConfigGetParameterActionProcessor(
|
|
62
|
-
...getConfigGetParametersActionProcessor(
|
|
57
|
+
...getCloudFrontOriginRequestEventActionProcessor(cdkConfig.qpqConfig),
|
|
58
|
+
...getConfigGetSecretActionProcessor(cdkConfig.qpqConfig, cdkConfig.awsResourceMap),
|
|
59
|
+
...getConfigGetParameterActionProcessor(cdkConfig.qpqConfig, cdkConfig.awsResourceMap),
|
|
60
|
+
...getConfigGetParametersActionProcessor(cdkConfig.qpqConfig, cdkConfig.awsResourceMap),
|
|
63
61
|
...getSystemActionProcessor(dynamicModuleLoader),
|
|
64
|
-
...getFileActionProcessor(
|
|
62
|
+
...getFileActionProcessor(cdkConfig.qpqConfig, cdkConfig.awsResourceMap),
|
|
65
63
|
|
|
66
|
-
...getCustomActionProcessors(
|
|
64
|
+
...getCustomActionProcessors(cdkConfig.qpqConfig, cdkConfig.awsResourceMap),
|
|
65
|
+
...qpqCustomActionProcessors(),
|
|
67
66
|
};
|
|
68
67
|
|
|
69
68
|
const logger = async (result: any) => {};
|
|
@@ -100,12 +99,19 @@ export const getOriginRequestEventExecutor = (
|
|
|
100
99
|
statusDescription: 'OK',
|
|
101
100
|
body: result.result.body,
|
|
102
101
|
headers: responseHeaders,
|
|
103
|
-
|
|
102
|
+
bodyEncoding: result.result.bodyEncoding,
|
|
103
|
+
} as CloudFrontRequestResult;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
// CloudFront seems to throw an error when you send back a 404 or something, so we will just hit the normal origin
|
|
107
107
|
return event.Records[0].cf.request;
|
|
108
108
|
|
|
109
|
+
/*return {
|
|
110
|
+
status: `200`,
|
|
111
|
+
statusDescription: 'OK',
|
|
112
|
+
body: `<pre>${JSON.stringify(result.error, null, 2)}</pre>`,
|
|
113
|
+
} as CloudFrontRequestResult;*/
|
|
114
|
+
|
|
109
115
|
// const code = ErrorTypeHttpResponseMap[result.error.errorType];
|
|
110
116
|
// return {
|
|
111
117
|
// statusCode: code || 500,
|
|
@@ -2,6 +2,8 @@ import { CloudFrontRequestEvent, Context } from 'aws-lambda';
|
|
|
2
2
|
|
|
3
3
|
export const getViewerRequestEventExecutor = () => {
|
|
4
4
|
return async (event: CloudFrontRequestEvent, context: Context) => {
|
|
5
|
+
console.log(JSON.stringify(event));
|
|
6
|
+
|
|
5
7
|
const request = event.Records[0].cf.request;
|
|
6
8
|
const headers = request.headers;
|
|
7
9
|
const customUserAgentHeaderName = 'x-qpq-is-bot';
|