quidproquo-deploy-awscdk 0.0.21 → 0.0.24
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/DeploymentSettings.d.ts +6 -0
- package/lib/DeploymentSettings.js +2 -0
- package/lib/DeploymentType.d.ts +5 -0
- package/lib/DeploymentType.js +9 -0
- package/lib/QPQApp.d.ts +2 -0
- package/lib/QPQApp.js +31 -0
- package/lib/QPQPrototypeSingleServiceStack.d.ts +14 -0
- package/lib/{QPQPrototypeStack.js → QPQPrototypeSingleServiceStack.js} +141 -29
- package/lib/index.d.ts +6 -1
- package/lib/index.js +6 -1
- package/lib/lambdas/index.d.ts +3 -0
- package/lib/lambdas/index.js +19 -0
- package/lib/lambdas/lambdaAPIGatewayEvent.d.ts +7 -2
- package/lib/lambdas/lambdaAPIGatewayEvent.js +39 -38
- package/lib/lambdas/lambdaConfig.d.ts +2 -0
- package/lib/lambdas/lambdaEventBridgeEvent.d.ts +3 -2
- package/lib/lambdas/lambdaEventBridgeEvent.js +14 -12
- package/lib/utils.d.ts +2 -0
- package/lib/utils.js +9 -0
- package/package.json +4 -4
- package/lib/QPQPrototypeStack.d.ts +0 -13
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeploymentType = void 0;
|
|
4
|
+
var DeploymentType;
|
|
5
|
+
(function (DeploymentType) {
|
|
6
|
+
DeploymentType["Dev"] = "development";
|
|
7
|
+
DeploymentType["Staging"] = "staging";
|
|
8
|
+
DeploymentType["Prod"] = "production";
|
|
9
|
+
})(DeploymentType = exports.DeploymentType || (exports.DeploymentType = {}));
|
package/lib/QPQApp.d.ts
ADDED
package/lib/QPQApp.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.createQPQApp = void 0;
|
|
27
|
+
const cdk = __importStar(require("aws-cdk-lib"));
|
|
28
|
+
const createQPQApp = () => {
|
|
29
|
+
return new cdk.App();
|
|
30
|
+
};
|
|
31
|
+
exports.createQPQApp = createQPQApp;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DeploymentSettings } from './DeploymentSettings';
|
|
2
|
+
import { Stack } from 'aws-cdk-lib';
|
|
3
|
+
import { Construct } from 'constructs';
|
|
4
|
+
export interface QPQPrototypeStackProps extends DeploymentSettings {
|
|
5
|
+
account: string;
|
|
6
|
+
region: string;
|
|
7
|
+
apiBuildPath: string;
|
|
8
|
+
webBuildPath: string;
|
|
9
|
+
lambdaAPIGatewayEventPath?: string;
|
|
10
|
+
lambdaEventBridgeEventPath?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare class QPQPrototypeSingleServiceStack extends Stack {
|
|
13
|
+
constructor(scope: Construct, id: string, props: QPQPrototypeStackProps);
|
|
14
|
+
}
|
|
@@ -23,21 +23,29 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.QPQPrototypeSingleServiceStack = void 0;
|
|
27
27
|
const path = __importStar(require("path"));
|
|
28
28
|
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
|
|
33
|
-
|
|
34
|
-
const apexDomain = quidproquo_webserver_1.qpqWebServerUtils.getDomainName(qpqConfig);
|
|
35
|
-
|
|
32
|
+
const DeploymentType_1 = require("./DeploymentType");
|
|
33
|
+
const getEnvironmentDomain = (stackProps) => {
|
|
34
|
+
const apexDomain = quidproquo_webserver_1.qpqWebServerUtils.getDomainName(stackProps.qpqConfig);
|
|
35
|
+
if (stackProps.environment === DeploymentType_1.DeploymentType.Prod) {
|
|
36
|
+
return apexDomain;
|
|
37
|
+
}
|
|
38
|
+
return `${stackProps.environment}.${apexDomain}`;
|
|
39
|
+
};
|
|
40
|
+
const createApiDomainName = (stack, id, stackProps) => {
|
|
41
|
+
const apexDomain = getEnvironmentDomain(stackProps);
|
|
42
|
+
const apiDomainName = `api.${apexDomain}`;
|
|
36
43
|
const apexHostedZone = aws_cdk_lib_1.aws_route53.HostedZone.fromLookup(stack, `${id}-apex-hostedZone`, {
|
|
37
44
|
domainName: apexDomain,
|
|
38
45
|
});
|
|
39
46
|
const certificate = new aws_cdk_lib_1.aws_certificatemanager.Certificate(stack, `${id}-api-certificate`, {
|
|
40
47
|
domainName: apiDomainName,
|
|
48
|
+
certificateName: `api-cert-${quidproquo_core_1.qpqCoreUtils.getAppName(stackProps.qpqConfig)}`,
|
|
41
49
|
validation: aws_cdk_lib_1.aws_certificatemanager.CertificateValidation.fromDns(apexHostedZone),
|
|
42
50
|
});
|
|
43
51
|
const domainName = new aws_cdk_lib_1.aws_apigateway.DomainName(stack, `${id}-api-custom-domain`, {
|
|
@@ -53,38 +61,136 @@ const createApiDomainName = (stack, id, qpqConfig) => {
|
|
|
53
61
|
});
|
|
54
62
|
return domainName;
|
|
55
63
|
};
|
|
56
|
-
|
|
57
|
-
|
|
64
|
+
const createWebDistribution = (stack, id, stackProps) => {
|
|
65
|
+
const apexDomain = getEnvironmentDomain(stackProps);
|
|
66
|
+
const serviceName = quidproquo_core_1.qpqCoreUtils.getAppName(stackProps.qpqConfig);
|
|
67
|
+
// create an s3 bucket
|
|
68
|
+
const staticWebFilesBucket = new aws_cdk_lib_1.aws_s3.Bucket(stack, `${id}-web`, {
|
|
69
|
+
bucketName: `${serviceName}-${stackProps.environment}-web`,
|
|
70
|
+
// Disable public access to this bucket, CloudFront will do that
|
|
71
|
+
publicReadAccess: false,
|
|
72
|
+
blockPublicAccess: aws_cdk_lib_1.aws_s3.BlockPublicAccess.BLOCK_ALL,
|
|
73
|
+
// Default website file
|
|
74
|
+
websiteIndexDocument: 'index.html',
|
|
75
|
+
// Allow bucket to auto delete upon cdk:Destroy
|
|
76
|
+
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
77
|
+
autoDeleteObjects: true,
|
|
78
|
+
});
|
|
79
|
+
// Create OriginAccessIdentity for the bucket.
|
|
80
|
+
const websiteOAI = new aws_cdk_lib_1.aws_cloudfront.OriginAccessIdentity(stack, `${id}-website-OAI`);
|
|
81
|
+
staticWebFilesBucket.grantRead(websiteOAI);
|
|
82
|
+
// Grab the hosted zone we want to add
|
|
83
|
+
const serviceHostedZone = aws_cdk_lib_1.aws_route53.HostedZone.fromLookup(stack, 'hosted-zone', {
|
|
84
|
+
domainName: apexDomain,
|
|
85
|
+
});
|
|
86
|
+
// Create a certificate for the distribution - Seems to a bug where Route 53 records not cleaned up
|
|
87
|
+
// after removing the DNS Validated certificate see: https://github.com/aws/aws-cdk/issues/3333
|
|
88
|
+
// `switch over to using the Certificate with the new built-in (CloudFormation-based) DNS validation`
|
|
89
|
+
const validationCertificate = aws_cdk_lib_1.aws_certificatemanager.CertificateValidation.fromDns(serviceHostedZone);
|
|
90
|
+
const certificate = new aws_cdk_lib_1.aws_certificatemanager.DnsValidatedCertificate(stack, `${id}-viewer-cert`, {
|
|
91
|
+
hostedZone: serviceHostedZone,
|
|
92
|
+
domainName: apexDomain,
|
|
93
|
+
region: 'us-east-1',
|
|
94
|
+
validation: validationCertificate,
|
|
95
|
+
});
|
|
96
|
+
const viewerCertificate = aws_cdk_lib_1.aws_cloudfront.ViewerCertificate.fromAcmCertificate(certificate, {
|
|
97
|
+
aliases: [apexDomain],
|
|
98
|
+
});
|
|
99
|
+
new aws_cdk_lib_1.aws_s3_deployment.BucketDeployment(stack, `${id}-DeployWebsite`, {
|
|
100
|
+
sources: [aws_cdk_lib_1.aws_s3_deployment.Source.asset(stackProps.webBuildPath)],
|
|
101
|
+
destinationBucket: staticWebFilesBucket,
|
|
102
|
+
});
|
|
103
|
+
// Create a cloud front distribution
|
|
104
|
+
// TODO: use aws_cloudfront.Distribution
|
|
105
|
+
const distribution = new aws_cdk_lib_1.aws_cloudfront.CloudFrontWebDistribution(stack, 'cf-distribution', {
|
|
106
|
+
originConfigs: [
|
|
107
|
+
{
|
|
108
|
+
s3OriginSource: {
|
|
109
|
+
s3BucketSource: staticWebFilesBucket,
|
|
110
|
+
originAccessIdentity: websiteOAI,
|
|
111
|
+
},
|
|
112
|
+
behaviors: [
|
|
113
|
+
...[
|
|
114
|
+
'/remoteEntry.js',
|
|
115
|
+
'/index.js',
|
|
116
|
+
'/index.html', // Add this if we need it
|
|
117
|
+
].map((pp) => ({
|
|
118
|
+
pathPattern: pp,
|
|
119
|
+
maxTtl: cdk.Duration.seconds(0),
|
|
120
|
+
minTtl: cdk.Duration.seconds(0),
|
|
121
|
+
defaultTtl: cdk.Duration.seconds(0),
|
|
122
|
+
})),
|
|
123
|
+
{
|
|
124
|
+
isDefaultBehavior: true,
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
viewerCertificate: viewerCertificate,
|
|
130
|
+
errorConfigurations: [
|
|
131
|
+
{
|
|
132
|
+
errorCode: 404,
|
|
133
|
+
responseCode: 200,
|
|
134
|
+
responsePagePath: '/',
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
});
|
|
138
|
+
// Create a cdn link
|
|
139
|
+
new aws_cdk_lib_1.aws_route53.ARecord(stack, `${id}-web-alias`, {
|
|
140
|
+
zone: serviceHostedZone,
|
|
141
|
+
recordName: apexDomain,
|
|
142
|
+
target: aws_cdk_lib_1.aws_route53.RecordTarget.fromAlias(new aws_cdk_lib_1.aws_route53_targets.CloudFrontTarget(distribution)),
|
|
143
|
+
});
|
|
144
|
+
return distribution;
|
|
145
|
+
};
|
|
146
|
+
class QPQPrototypeSingleServiceStack extends aws_cdk_lib_1.Stack {
|
|
147
|
+
constructor(scope, id, props) {
|
|
148
|
+
super(scope, id, {
|
|
149
|
+
env: {
|
|
150
|
+
account: props.account,
|
|
151
|
+
region: props.region,
|
|
152
|
+
},
|
|
153
|
+
});
|
|
58
154
|
const settings = {
|
|
59
155
|
environment: props.environment,
|
|
60
156
|
service: quidproquo_core_1.qpqCoreUtils.getAppName(props.qpqConfig),
|
|
61
|
-
id: `${quidproquo_core_1.qpqCoreUtils.getAppName(props.qpqConfig)}-${props.environment}`,
|
|
62
157
|
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
region: props.region,
|
|
66
|
-
} }));
|
|
67
|
-
const domainName = createApiDomainName(this, settings.id, props.qpqConfig);
|
|
158
|
+
const domainName = createApiDomainName(this, id, props);
|
|
159
|
+
createWebDistribution(this, `${id}-web-dist`, props);
|
|
68
160
|
const resourceName = (name) => {
|
|
69
161
|
return `${settings.service}-${settings.environment}-${name}`;
|
|
70
162
|
};
|
|
71
|
-
const BLLayer = new
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
});
|
|
163
|
+
// const BLLayer = new aws_lambda.LayerVersion(this, `${id}-BLLayer`, {
|
|
164
|
+
// layerVersionName: `${id}-BLLayer`,
|
|
165
|
+
// code: new aws_lambda.AssetCode(props.apiBuildPath),
|
|
166
|
+
// compatibleRuntimes: [aws_lambda.Runtime.NODEJS_16_X],
|
|
167
|
+
// });
|
|
76
168
|
const ownedSecrets = quidproquo_core_1.qpqCoreUtils.getOwnedSecrets(props.qpqConfig).map((secret) => {
|
|
77
169
|
const realSecretName = `${secret.key}-${settings.service}-${settings.environment}`;
|
|
78
170
|
return {
|
|
79
171
|
secretName: secret.key,
|
|
80
172
|
realName: realSecretName,
|
|
81
|
-
secret: new aws_cdk_lib_1.aws_secretsmanager.Secret(this, `${
|
|
173
|
+
secret: new aws_cdk_lib_1.aws_secretsmanager.Secret(this, `${id}-secret-${secret.key}`, {
|
|
82
174
|
secretName: realSecretName,
|
|
83
175
|
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
84
176
|
description: `${settings.environment}-${settings.service}`,
|
|
85
177
|
}),
|
|
86
178
|
};
|
|
87
179
|
});
|
|
180
|
+
const ownedParameters = quidproquo_core_1.qpqCoreUtils.getOwnedParameters(props.qpqConfig).map((parameter) => {
|
|
181
|
+
const realParameterName = `${parameter.key}-${settings.service}-${settings.environment}`;
|
|
182
|
+
return {
|
|
183
|
+
parameterName: parameter.key,
|
|
184
|
+
realName: realParameterName,
|
|
185
|
+
parameter: new aws_cdk_lib_1.aws_ssm.StringParameter(this, `${id}-parameter-${parameter.key}`, {
|
|
186
|
+
parameterName: realParameterName,
|
|
187
|
+
description: `${settings.environment}-${settings.service}`,
|
|
188
|
+
stringValue: parameter.value,
|
|
189
|
+
// No additional costs ~ 4k max size
|
|
190
|
+
tier: aws_cdk_lib_1.aws_ssm.ParameterTier.STANDARD,
|
|
191
|
+
}),
|
|
192
|
+
};
|
|
193
|
+
});
|
|
88
194
|
const buckets = quidproquo_core_1.qpqCoreUtils.getStorageDriveNames(props.qpqConfig).map((driveName) => {
|
|
89
195
|
const bucketName = resourceName(driveName);
|
|
90
196
|
const bucket = new aws_cdk_lib_1.aws_s3.Bucket(this, bucketName, {
|
|
@@ -106,15 +212,18 @@ class QPQPrototypeStack extends aws_cdk_lib_1.Stack {
|
|
|
106
212
|
const runtimeConfigLambdaConfig = {
|
|
107
213
|
qpqConfig: props.qpqConfig,
|
|
108
214
|
secretNameMap: ownedSecrets.reduce((acc, os) => (Object.assign(Object.assign({}, acc), { [os.secretName]: os.realName })), {}),
|
|
215
|
+
parameterNameMap: ownedParameters.reduce((acc, os) => (Object.assign(Object.assign({}, acc), { [os.parameterName]: os.realName })), {}),
|
|
109
216
|
resourceNameMap: buckets.reduce((acc, b) => (Object.assign(Object.assign({}, acc), { [b.driveName]: b.bucketName })), {}),
|
|
110
217
|
};
|
|
111
218
|
const lambdaHandler = new aws_cdk_lib_1.aws_lambda_nodejs.NodejsFunction(this, `${settings.environment}-${settings.service}-lambda-rest`, {
|
|
112
219
|
functionName: `lambda-rest-${settings.service}-${settings.environment}`,
|
|
113
|
-
entry:
|
|
114
|
-
|
|
220
|
+
entry: props.lambdaAPIGatewayEventPath ||
|
|
221
|
+
path.resolve(__dirname, 'lambdas', 'lambdaAPIGatewayEvent.js'),
|
|
222
|
+
handler: 'executeAPIGatewayEvent',
|
|
115
223
|
timeout: cdk.Duration.seconds(25),
|
|
116
224
|
runtime: aws_cdk_lib_1.aws_lambda.Runtime.NODEJS_16_X,
|
|
117
|
-
layers: [BLLayer],
|
|
225
|
+
// layers: [BLLayer],
|
|
226
|
+
memorySize: 1024,
|
|
118
227
|
bundling: {
|
|
119
228
|
tsconfig: './tsconfig.json',
|
|
120
229
|
define: {
|
|
@@ -128,6 +237,7 @@ class QPQPrototypeStack extends aws_cdk_lib_1.Stack {
|
|
|
128
237
|
// Grant access to the lambda
|
|
129
238
|
buckets.forEach((b) => b.bucket.grantReadWrite(lambdaHandler));
|
|
130
239
|
ownedSecrets.forEach((os) => os.secret.grantRead(lambdaHandler));
|
|
240
|
+
ownedParameters.forEach((os) => os.parameter.grantRead(lambdaHandler));
|
|
131
241
|
// Create a rest api
|
|
132
242
|
const api = new aws_cdk_lib_1.aws_apigateway.LambdaRestApi(this, `${settings.environment}-${settings.service}-http-api`, {
|
|
133
243
|
restApiName: `${settings.environment}-${settings.service}-http-api`,
|
|
@@ -139,7 +249,7 @@ class QPQPrototypeStack extends aws_cdk_lib_1.Stack {
|
|
|
139
249
|
proxy: true,
|
|
140
250
|
});
|
|
141
251
|
// Map all requests to this service to /serviceName/*
|
|
142
|
-
new aws_cdk_lib_1.aws_apigateway.BasePathMapping(this, `${
|
|
252
|
+
new aws_cdk_lib_1.aws_apigateway.BasePathMapping(this, `${id}-rest-bpm`, {
|
|
143
253
|
domainName: domainName,
|
|
144
254
|
restApi: api,
|
|
145
255
|
// the properties below are optional
|
|
@@ -148,12 +258,13 @@ class QPQPrototypeStack extends aws_cdk_lib_1.Stack {
|
|
|
148
258
|
quidproquo_core_1.qpqCoreUtils.getScheduleEvents(props.qpqConfig).forEach((se, index) => {
|
|
149
259
|
const schedulerFunction = new aws_cdk_lib_1.aws_lambda_nodejs.NodejsFunction(this, `${settings.environment}-${settings.service}-SE-${index}`, {
|
|
150
260
|
functionName: `SE-${index}-${se.runtime}-${settings.environment}-${settings.service}`,
|
|
151
|
-
entry:
|
|
261
|
+
entry: props.lambdaEventBridgeEventPath ||
|
|
262
|
+
path.resolve(__dirname, 'lambdas', 'lambdaEventBridgeEvent.js'),
|
|
152
263
|
handler: 'execute',
|
|
153
264
|
timeout: cdk.Duration.minutes(15),
|
|
154
265
|
runtime: aws_cdk_lib_1.aws_lambda.Runtime.NODEJS_16_X,
|
|
155
|
-
|
|
156
|
-
|
|
266
|
+
// layers: [BLLayer],
|
|
267
|
+
memorySize: 1024,
|
|
157
268
|
bundling: {
|
|
158
269
|
tsconfig: './tsconfig.json',
|
|
159
270
|
define: {
|
|
@@ -169,13 +280,14 @@ class QPQPrototypeStack extends aws_cdk_lib_1.Stack {
|
|
|
169
280
|
});
|
|
170
281
|
buckets.forEach((b) => b.bucket.grantReadWrite(schedulerFunction));
|
|
171
282
|
ownedSecrets.forEach((os) => os.secret.grantRead(schedulerFunction));
|
|
283
|
+
ownedParameters.forEach((os) => os.parameter.grantRead(schedulerFunction));
|
|
172
284
|
// EventBridge rule which runs every five minutes
|
|
173
|
-
const cronRule = new aws_cdk_lib_1.aws_events.Rule(this, `${
|
|
285
|
+
const cronRule = new aws_cdk_lib_1.aws_events.Rule(this, `${id}-se-cronrule-${index}`, {
|
|
174
286
|
schedule: aws_cdk_lib_1.aws_events.Schedule.expression(`cron(${se.cronExpression})`),
|
|
175
287
|
});
|
|
176
|
-
// Set the
|
|
288
|
+
// Set the target as lambda function
|
|
177
289
|
cronRule.addTarget(new aws_cdk_lib_1.aws_events_targets.LambdaFunction(schedulerFunction));
|
|
178
290
|
});
|
|
179
291
|
}
|
|
180
292
|
}
|
|
181
|
-
exports.
|
|
293
|
+
exports.QPQPrototypeSingleServiceStack = QPQPrototypeSingleServiceStack;
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -14,4 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./utils"), exports);
|
|
18
|
+
__exportStar(require("./DeploymentType"), exports);
|
|
19
|
+
__exportStar(require("./DeploymentSettings"), exports);
|
|
20
|
+
__exportStar(require("./QPQApp"), exports);
|
|
21
|
+
__exportStar(require("./QPQPrototypeSingleServiceStack"), exports);
|
|
22
|
+
__exportStar(require("./lambdas"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./lambdaConfig"), exports);
|
|
18
|
+
__exportStar(require("./lambdaAPIGatewayEvent"), exports);
|
|
19
|
+
__exportStar(require("./lambdaEventBridgeEvent"), exports);
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { Context } from 'aws-lambda';
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
2
|
+
import { ActionProcessorListResolver } from './lambdaConfig';
|
|
3
|
+
export declare const getAPIGatewayEventExecutor: (getCustomActionProcessors?: ActionProcessorListResolver) => (event: import("aws-lambda").APIGatewayProxyEvent, context: Context) => Promise<{
|
|
4
|
+
statusCode: any;
|
|
5
|
+
body: string;
|
|
6
|
+
headers: any;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const executeAPIGatewayEvent: (event: import("aws-lambda").APIGatewayProxyEvent, context: Context) => Promise<{
|
|
4
9
|
statusCode: any;
|
|
5
10
|
body: string;
|
|
6
11
|
headers: any;
|
|
@@ -9,13 +9,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.executeAPIGatewayEvent = exports.getAPIGatewayEventExecutor = void 0;
|
|
13
13
|
const quidproquo_actionprocessor_node_1 = require("quidproquo-actionprocessor-node");
|
|
14
14
|
const quidproquo_actionprocessor_awslambda_1 = require("quidproquo-actionprocessor-awslambda");
|
|
15
15
|
const quidproquo_core_1 = require("quidproquo-core");
|
|
16
16
|
const lambdaConfig_1 = require("./lambdaConfig");
|
|
17
|
+
// TODO: Make this a util or something based on server time or something..
|
|
17
18
|
const getDateNow = () => new Date().toISOString();
|
|
18
|
-
exports.getDateNow = getDateNow;
|
|
19
19
|
const ErrorTypeHttpResponseMap = {
|
|
20
20
|
[quidproquo_core_1.ErrorTypeEnum.BadRequest]: 400,
|
|
21
21
|
[quidproquo_core_1.ErrorTypeEnum.Unauthorized]: 401,
|
|
@@ -28,42 +28,43 @@ const ErrorTypeHttpResponseMap = {
|
|
|
28
28
|
[quidproquo_core_1.ErrorTypeEnum.GenericError]: 500,
|
|
29
29
|
[quidproquo_core_1.ErrorTypeEnum.NotImplemented]: 501,
|
|
30
30
|
[quidproquo_core_1.ErrorTypeEnum.NoContent]: 204,
|
|
31
|
+
[quidproquo_core_1.ErrorTypeEnum.Invalid]: 422,
|
|
31
32
|
};
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
33
|
+
const getAPIGatewayEventExecutor = (getCustomActionProcessors = () => ({})) => {
|
|
34
|
+
return (event, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
+
// Build a processor for the session and stuff
|
|
36
|
+
// Remove the non route ones ~ let the story execute action add them
|
|
37
|
+
const storyActionProcessor = 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)(lambdaConfig_1.lambdaRuntimeConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetSecretActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParameterActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getSystemActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getFileActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), getCustomActionProcessors(lambdaConfig_1.lambdaRuntimeConfig));
|
|
38
|
+
const logger = (result) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
+
// addResult(
|
|
40
|
+
// envConfig.appName,
|
|
41
|
+
// getDateNow(),
|
|
42
|
+
// doWeCarePath,
|
|
43
|
+
// "route-infrastructure",
|
|
44
|
+
// "infrastructure",
|
|
45
|
+
// "askRoute",
|
|
46
|
+
// result
|
|
47
|
+
// );
|
|
48
|
+
});
|
|
49
|
+
// // Run the callback
|
|
50
|
+
const resolveStory = (0, quidproquo_core_1.createRuntime)({}, storyActionProcessor, getDateNow, logger, quidproquo_actionprocessor_awslambda_1.awsLambdaUtils.randomGuid);
|
|
51
|
+
const result = yield resolveStory(quidproquo_core_1.askProcessEvent, [event, context]);
|
|
52
|
+
// // Run the callback
|
|
53
|
+
if (!result.error) {
|
|
54
|
+
return {
|
|
55
|
+
statusCode: result.result.statusCode,
|
|
56
|
+
body: JSON.stringify(result.result.body),
|
|
57
|
+
headers: result.result.headers,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const code = ErrorTypeHttpResponseMap[result.error.errorType];
|
|
56
61
|
return {
|
|
57
|
-
statusCode:
|
|
58
|
-
body: JSON.stringify(result.error
|
|
59
|
-
headers:
|
|
62
|
+
statusCode: code || 500,
|
|
63
|
+
body: JSON.stringify(result.error),
|
|
64
|
+
headers: {},
|
|
60
65
|
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
headers: {},
|
|
67
|
-
};
|
|
68
|
-
});
|
|
69
|
-
exports.execute = execute;
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
exports.getAPIGatewayEventExecutor = getAPIGatewayEventExecutor;
|
|
69
|
+
// Default executor
|
|
70
|
+
exports.executeAPIGatewayEvent = (0, exports.getAPIGatewayEventExecutor)();
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import { ActionProcessorList } from 'quidproquo-core';
|
|
1
2
|
import { QPQAWSLambdaConfig } from 'quidproquo-actionprocessor-awslambda';
|
|
2
3
|
export declare const lambdaRuntimeConfig: QPQAWSLambdaConfig;
|
|
4
|
+
export type ActionProcessorListResolver = (lambdaRuntimeConfig: QPQAWSLambdaConfig) => ActionProcessorList;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { EventBridgeEvent, Context } from 'aws-lambda';
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
2
|
+
import { ActionProcessorListResolver } from './lambdaConfig';
|
|
3
|
+
export declare const getEventBridgeEventExecutor: (getCustomActionProcessors?: ActionProcessorListResolver) => (event: EventBridgeEvent<string, void>, context: Context) => Promise<void>;
|
|
4
|
+
export declare const executeEventBridgeEvent: (event: EventBridgeEvent<string, void>, context: Context) => Promise<void>;
|
|
@@ -9,21 +9,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.executeEventBridgeEvent = exports.getEventBridgeEventExecutor = void 0;
|
|
13
13
|
const quidproquo_actionprocessor_node_1 = require("quidproquo-actionprocessor-node");
|
|
14
14
|
const quidproquo_actionprocessor_awslambda_1 = require("quidproquo-actionprocessor-awslambda");
|
|
15
15
|
const quidproquo_core_1 = require("quidproquo-core");
|
|
16
16
|
const lambdaConfig_1 = require("./lambdaConfig");
|
|
17
17
|
// TODO: Make this a util or something based on server time or something..
|
|
18
18
|
const getDateNow = () => new Date().toISOString();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
29
|
-
|
|
19
|
+
const getEventBridgeEventExecutor = (getCustomActionProcessors = () => ({})) => {
|
|
20
|
+
return (event, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
// Build a processor for the session and stuff
|
|
22
|
+
// Remove the non event ones
|
|
23
|
+
const storyActionProcessor = 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)(lambdaConfig_1.lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getSystemActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getFileActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetSecretActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParameterActionProcessor)(lambdaConfig_1.lambdaRuntimeConfig)), getCustomActionProcessors(lambdaConfig_1.lambdaRuntimeConfig));
|
|
24
|
+
const logger = (result) => __awaiter(void 0, void 0, void 0, function* () { });
|
|
25
|
+
// Run the callback
|
|
26
|
+
const resolveStory = (0, quidproquo_core_1.createRuntime)({}, storyActionProcessor, getDateNow, logger, quidproquo_actionprocessor_awslambda_1.awsLambdaUtils.randomGuid);
|
|
27
|
+
yield resolveStory(quidproquo_core_1.askProcessEvent, [event, context]);
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
exports.getEventBridgeEventExecutor = getEventBridgeEventExecutor;
|
|
31
|
+
exports.executeEventBridgeEvent = (0, exports.getEventBridgeEventExecutor)();
|
package/lib/utils.d.ts
ADDED
package/lib/utils.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStackName = void 0;
|
|
4
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
5
|
+
const getStackName = (deploymentSettings) => {
|
|
6
|
+
const appName = quidproquo_core_1.qpqCoreUtils.getAppName(deploymentSettings.qpqConfig);
|
|
7
|
+
return `${appName}-${deploymentSettings.environment}`;
|
|
8
|
+
};
|
|
9
|
+
exports.getStackName = getStackName;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quidproquo-deploy-awscdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.js",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
},
|
|
25
25
|
"homepage": "https://github.com/joe-coady/quidproquo#readme",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"aws-cdk-lib": "2.
|
|
28
|
-
"aws-cdk": "2.
|
|
29
|
-
"constructs": "^10.
|
|
27
|
+
"aws-cdk-lib": "^2.55.1",
|
|
28
|
+
"aws-cdk": "^2.55.1",
|
|
29
|
+
"constructs": "^10.1.191",
|
|
30
30
|
"esbuild": "^0.15.16",
|
|
31
31
|
"quidproquo-actionprocessor-awslambda": "*",
|
|
32
32
|
"quidproquo-actionprocessor-node": "*",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Stack, StackProps } from 'aws-cdk-lib';
|
|
2
|
-
import { Construct } from 'constructs';
|
|
3
|
-
import { QPQConfig } from 'quidproquo-core';
|
|
4
|
-
export interface QPQPrototypeStackProps extends StackProps {
|
|
5
|
-
environment: string;
|
|
6
|
-
serviceBuildPath: string;
|
|
7
|
-
qpqConfig: QPQConfig;
|
|
8
|
-
account: string;
|
|
9
|
-
region: string;
|
|
10
|
-
}
|
|
11
|
-
export declare class QPQPrototypeStack extends Stack {
|
|
12
|
-
constructor(scope: Construct, props: QPQPrototypeStackProps);
|
|
13
|
-
}
|