quidproquo-deploy-awscdk 0.0.48 → 0.0.49

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.
@@ -7,6 +7,7 @@ export interface QPQPrototypeStackProps extends DeploymentSettings {
7
7
  webBuildPath: string;
8
8
  lambdaAPIGatewayEventPath?: string;
9
9
  lambdaEventBridgeEventPath?: string;
10
+ layers?: string[];
10
11
  }
11
12
  export declare class QPQPrototypeSingleServiceStack extends Stack {
12
13
  constructor(scope: Construct, id: string, props: QPQPrototypeStackProps);
@@ -258,17 +258,20 @@ 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],
261
+ const customLayers = (props.layers || []).map((layer, index) => {
262
+ const layerName = `${layer.split('/').pop()}-${index}-${settings.environment}-${settings.service}`;
263
+ return new aws_cdk_lib_1.aws_lambda.LayerVersion(this, `${id}-${layerName}`, {
264
+ layerVersionName: `${layerName}`,
265
+ code: new aws_cdk_lib_1.aws_lambda.AssetCode(layer),
266
+ compatibleRuntimes: [aws_cdk_lib_1.aws_lambda.Runtime.NODEJS_16_X],
267
+ });
265
268
  });
266
269
  const lambdaHandler = new aws_cdk_lib_1.aws_lambda.Function(this, `${settings.environment}-${settings.service}-lambda-rest`, {
267
270
  functionName: `lambda-rest-${settings.service}-${settings.environment}`,
268
271
  timeout: cdk.Duration.seconds(25),
269
272
  runtime: aws_cdk_lib_1.aws_lambda.Runtime.NODEJS_16_X,
270
273
  memorySize: 1024,
271
- layers: [BLLayer],
274
+ layers: customLayers,
272
275
  code: aws_cdk_lib_1.aws_lambda.Code.fromAsset(path.join(props.apiBuildPath, 'lambdaAPIGatewayEvent')),
273
276
  handler: 'index.executeAPIGatewayEvent',
274
277
  environment: {
@@ -302,6 +305,7 @@ class QPQPrototypeSingleServiceStack extends aws_cdk_lib_1.Stack {
302
305
  timeout: cdk.Duration.minutes(15),
303
306
  runtime: aws_cdk_lib_1.aws_lambda.Runtime.NODEJS_16_X,
304
307
  memorySize: 1024,
308
+ layers: customLayers,
305
309
  code: aws_cdk_lib_1.aws_lambda.Code.fromAsset(path.join(props.apiBuildPath, 'lambdaEventBridgeEvent')),
306
310
  handler: 'index.executeEventBridgeEvent',
307
311
  environment: {
@@ -7,9 +7,9 @@ export declare const getViewerRequestEventExecutor: () => (event: CloudFrontRequ
7
7
  }[];
8
8
  };
9
9
  body?: {
10
- action: "read-only" | "replace";
10
+ action: "replace" | "read-only";
11
11
  data: string;
12
- encoding: "base64" | "text";
12
+ encoding: "text" | "base64";
13
13
  readonly inputTruncated: boolean;
14
14
  } | undefined;
15
15
  clientIp: string;
@@ -26,9 +26,9 @@ export declare const executeEventViewerRequest: (event: CloudFrontRequestEvent,
26
26
  }[];
27
27
  };
28
28
  body?: {
29
- action: "read-only" | "replace";
29
+ action: "replace" | "read-only";
30
30
  data: string;
31
- encoding: "base64" | "text";
31
+ encoding: "text" | "base64";
32
32
  readonly inputTruncated: boolean;
33
33
  } | undefined;
34
34
  clientIp: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quidproquo-deploy-awscdk",
3
- "version": "0.0.48",
3
+ "version": "0.0.49",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.js",
@@ -11,7 +11,7 @@
11
11
  "scripts": {
12
12
  "test": "echo \"Error: no test specified\" && exit 1",
13
13
  "clean": "npx rimraf lib",
14
- "build": "",
14
+ "build": "npm run clean && tsc",
15
15
  "watch": "tsc -w"
16
16
  },
17
17
  "repository": {
@@ -1,51 +0,0 @@
1
- interface CloudFrontConfig {
2
- distributionDomainName: string;
3
- distributionId: string;
4
- eventType: string;
5
- requestId: string;
6
- }
7
- interface Body {
8
- action: string;
9
- data: string;
10
- encoding: string;
11
- inputTruncated: boolean;
12
- }
13
- interface KeyValueHeader {
14
- key: string;
15
- value: string;
16
- }
17
- interface Headers {
18
- [key: string]: KeyValueHeader[];
19
- }
20
- interface CustomHeaders {
21
- }
22
- interface S3 {
23
- authMethod: string;
24
- customHeaders: CustomHeaders;
25
- domainName: string;
26
- path: string;
27
- region: string;
28
- }
29
- interface Origin {
30
- s3: S3;
31
- }
32
- interface CloudFrontOriginRequest {
33
- body?: Body;
34
- clientIp: string;
35
- headers: Headers;
36
- method: string;
37
- origin: Origin;
38
- querystring: string;
39
- uri: string;
40
- }
41
- interface CloudFrontOriginConfigRequest {
42
- config: CloudFrontConfig;
43
- request: CloudFrontOriginRequest;
44
- }
45
- interface CloudFrontRecord {
46
- cf: CloudFrontOriginConfigRequest;
47
- }
48
- export interface CloudFrontOriginRequestEvent {
49
- Records: CloudFrontRecord[];
50
- }
51
- export {};
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +0,0 @@
1
- import { ActionProcessorList } from 'quidproquo-core';
2
- import { QPQAWSLambdaConfig } from 'quidproquo-actionprocessor-awslambda';
3
- export declare const lambdaRuntimeConfig: QPQAWSLambdaConfig;
4
- export type ActionProcessorListResolver = (lambdaRuntimeConfig: QPQAWSLambdaConfig) => ActionProcessorList;
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.lambdaRuntimeConfig = void 0;
4
- exports.lambdaRuntimeConfig = JSON.parse(process.env.lambdaRuntimeConfig || '{}');
@@ -1,5 +0,0 @@
1
- import { DynamicModuleLoader } from 'quidproquo-actionprocessor-awslambda';
2
- import { CloudFrontRequestEvent, Context } from 'aws-lambda';
3
- import { ActionProcessorListResolver } from './actionProcessorListResolver';
4
- export declare const getOriginRequestEventExecutor: (dynamicModuleLoader: DynamicModuleLoader, getCustomActionProcessors?: ActionProcessorListResolver) => (event: CloudFrontRequestEvent, context: Context) => Promise<any>;
5
- export declare const executeEventOriginRequest: (event: CloudFrontRequestEvent, context: Context) => Promise<any>;
@@ -1,74 +0,0 @@
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
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.executeEventOriginRequest = exports.getOriginRequestEventExecutor = void 0;
16
- const quidproquo_actionprocessor_node_1 = require("quidproquo-actionprocessor-node");
17
- const quidproquo_actionprocessor_awslambda_1 = require("quidproquo-actionprocessor-awslambda");
18
- const quidproquo_core_1 = require("quidproquo-core");
19
- // @ts-ignore - Special webpack loader
20
- const qpq_dynamic_loader_1 = __importDefault(require("qpq-dynamic-loader!"));
21
- // @ts-ignore - Special webpack loader
22
- // import qpqConfig from 'qpq-config-loader!';
23
- // TODO: Make this a util or something based on server time or something..
24
- const getDateNow = () => new Date().toISOString();
25
- const ErrorTypeHttpResponseMap = {
26
- [quidproquo_core_1.ErrorTypeEnum.NoContent]: 204,
27
- [quidproquo_core_1.ErrorTypeEnum.BadRequest]: 400,
28
- [quidproquo_core_1.ErrorTypeEnum.Unauthorized]: 401,
29
- [quidproquo_core_1.ErrorTypeEnum.PaymentRequired]: 402,
30
- [quidproquo_core_1.ErrorTypeEnum.Forbidden]: 403,
31
- [quidproquo_core_1.ErrorTypeEnum.NotFound]: 404,
32
- [quidproquo_core_1.ErrorTypeEnum.TimeOut]: 408,
33
- [quidproquo_core_1.ErrorTypeEnum.UnsupportedMediaType]: 415,
34
- [quidproquo_core_1.ErrorTypeEnum.Invalid]: 422,
35
- [quidproquo_core_1.ErrorTypeEnum.OutOfResources]: 500,
36
- [quidproquo_core_1.ErrorTypeEnum.GenericError]: 500,
37
- [quidproquo_core_1.ErrorTypeEnum.NotImplemented]: 501,
38
- };
39
- const getOriginRequestEventExecutor = (dynamicModuleLoader, getCustomActionProcessors = () => ({})) => {
40
- return (event, context) => __awaiter(void 0, void 0, void 0, function* () {
41
- console.log('AAAAAAAAAAAAAAAAA');
42
- // TODO: Make this error safe
43
- const param = yield (0, quidproquo_actionprocessor_awslambda_1.getParameter)('qpqRuntimeConfig-theconspiracytest-development');
44
- const lambdaRuntimeConfig = JSON.parse(param);
45
- // //////////////////////////
46
- console.log('BBBBBBBBBB');
47
- // Build a processor for the session and stuff
48
- // Remove the non route ones ~ let the story execute action add them
49
- 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)(lambdaRuntimeConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetSecretActionProcessor)(lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParameterActionProcessor)(lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParametersActionProcessor)(lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getSystemActionProcessor)(dynamicModuleLoader)), (0, quidproquo_actionprocessor_awslambda_1.getFileActionProcessor)(lambdaRuntimeConfig)), getCustomActionProcessors(lambdaRuntimeConfig));
50
- console.log('CCCCCCCCCCCCCCC');
51
- const logger = (result) => __awaiter(void 0, void 0, void 0, function* () { });
52
- // Run the callback
53
- const resolveStory = (0, quidproquo_core_1.createRuntime)({}, storyActionProcessor, getDateNow, logger, quidproquo_actionprocessor_awslambda_1.awsLambdaUtils.randomGuid);
54
- console.log('DDDDDDDDDDDD');
55
- const result = yield resolveStory(quidproquo_core_1.askProcessEvent, [event, context]);
56
- console.log('EEEEEEEEEEEEEE');
57
- console.log(JSON.stringify(result));
58
- // Run the callback
59
- if (!result.error) {
60
- return result.result;
61
- }
62
- console.log('FFFFFFFFFFFFFFFFFFF');
63
- const code = ErrorTypeHttpResponseMap[result.error.errorType];
64
- return {
65
- statusCode: code || 500,
66
- statusDescription: result.error.errorType,
67
- body: JSON.stringify(result.error),
68
- headers: {},
69
- };
70
- });
71
- };
72
- exports.getOriginRequestEventExecutor = getOriginRequestEventExecutor;
73
- // Default executor
74
- exports.executeEventOriginRequest = (0, exports.getOriginRequestEventExecutor)(qpq_dynamic_loader_1.default);
@@ -1,51 +0,0 @@
1
- interface CloudFrontConfig {
2
- distributionDomainName: string;
3
- distributionId: string;
4
- eventType: string;
5
- requestId: string;
6
- }
7
- interface Body {
8
- action: string;
9
- data: string;
10
- encoding: string;
11
- inputTruncated: boolean;
12
- }
13
- interface KeyValueHeader {
14
- key: string;
15
- value: string;
16
- }
17
- interface Headers {
18
- [key: string]: KeyValueHeader[];
19
- }
20
- interface CustomHeaders {
21
- }
22
- interface S3 {
23
- authMethod: string;
24
- customHeaders: CustomHeaders;
25
- domainName: string;
26
- path: string;
27
- region: string;
28
- }
29
- interface Origin {
30
- s3: S3;
31
- }
32
- interface CloudFrontOriginRequest {
33
- body?: Body;
34
- clientIp: string;
35
- headers: Headers;
36
- method: string;
37
- origin: Origin;
38
- querystring: string;
39
- uri: string;
40
- }
41
- interface CloudFrontOriginConfigRequest {
42
- config: CloudFrontConfig;
43
- request: CloudFrontOriginRequest;
44
- }
45
- interface CloudFrontRecord {
46
- cf: CloudFrontOriginConfigRequest;
47
- }
48
- export interface CloudFrontOriginRequestEvent {
49
- Records: CloudFrontRecord[];
50
- }
51
- export {};
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });