quidproquo-deploy-awscdk 0.0.231 → 0.0.232
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/commonjs/constructs/basic/Function.d.ts +0 -1
- package/lib/commonjs/constructs/basic/Function.js +1 -1
- package/lib/commonjs/constructs/basic/index.d.ts +0 -1
- package/lib/commonjs/constructs/basic/index.js +0 -1
- package/lib/commonjs/constructs/feature/core/auth/QpqInfCoreUserDirectoryConstruct.js +0 -4
- package/lib/commonjs/constructs/feature/core/deployEvents/QpqCoreDeployEventConstruct.js +0 -2
- package/lib/commonjs/constructs/feature/core/queue/QpqApiCoreQueueConstruct.js +0 -1
- package/lib/commonjs/constructs/feature/core/schedule/QpqCoreRecurringScheduleConstruct.js +0 -2
- package/lib/commonjs/constructs/feature/core/storageDrive/QpqApiCoreStorageDriveConstruct.js +0 -3
- package/lib/commonjs/constructs/feature/webserver/api/ApiQpqWebserverApiConstruct.js +0 -1
- package/lib/commonjs/constructs/feature/webserver/redirect/QpqWebserverSubdomainRedirectConstruct.js +0 -1
- package/lib/commonjs/constructs/feature/webserver/serviceFunction/QpqWebserverServiceFunctionConstruct.js +0 -2
- package/lib/commonjs/constructs/feature/webserver/webEntry/WebQpqWebserverWebEntryConstruct.js +2 -1
- package/lib/commonjs/constructs/feature/webserver/websocket/QpqApiWebserverWebsocketConstruct.js +0 -1
- package/lib/esm/constructs/basic/Function.d.ts +0 -1
- package/lib/esm/constructs/basic/Function.js +1 -1
- package/lib/esm/constructs/basic/index.d.ts +0 -1
- package/lib/esm/constructs/basic/index.js +0 -1
- package/lib/esm/constructs/feature/core/auth/QpqInfCoreUserDirectoryConstruct.js +0 -4
- package/lib/esm/constructs/feature/core/deployEvents/QpqCoreDeployEventConstruct.js +0 -2
- package/lib/esm/constructs/feature/core/queue/QpqApiCoreQueueConstruct.js +0 -1
- package/lib/esm/constructs/feature/core/schedule/QpqCoreRecurringScheduleConstruct.js +0 -2
- package/lib/esm/constructs/feature/core/storageDrive/QpqApiCoreStorageDriveConstruct.js +0 -3
- package/lib/esm/constructs/feature/webserver/api/ApiQpqWebserverApiConstruct.js +0 -1
- package/lib/esm/constructs/feature/webserver/redirect/QpqWebserverSubdomainRedirectConstruct.js +0 -1
- package/lib/esm/constructs/feature/webserver/serviceFunction/QpqWebserverServiceFunctionConstruct.js +0 -2
- package/lib/esm/constructs/feature/webserver/webEntry/WebQpqWebserverWebEntryConstruct.js +2 -1
- package/lib/esm/constructs/feature/webserver/websocket/QpqApiWebserverWebsocketConstruct.js +0 -1
- package/package.json +7 -7
- package/src/constructs/basic/Function.ts +1 -2
- package/src/constructs/basic/index.ts +0 -1
- package/src/constructs/feature/core/auth/QpqInfCoreUserDirectoryConstruct.ts +0 -4
- package/src/constructs/feature/core/deployEvents/QpqCoreDeployEventConstruct.ts +0 -1
- package/src/constructs/feature/core/queue/QpqApiCoreQueueConstruct.ts +0 -1
- package/src/constructs/feature/core/schedule/QpqCoreRecurringScheduleConstruct.ts +0 -1
- package/src/constructs/feature/core/storageDrive/QpqApiCoreStorageDriveConstruct.ts +0 -4
- package/src/constructs/feature/webserver/api/ApiQpqWebserverApiConstruct.ts +0 -1
- package/src/constructs/feature/webserver/redirect/QpqWebserverSubdomainRedirectConstruct.ts +0 -1
- package/src/constructs/feature/webserver/serviceFunction/QpqWebserverServiceFunctionConstruct.ts +2 -2
- package/src/constructs/feature/webserver/webEntry/WebQpqWebserverWebEntryConstruct.ts +2 -1
- package/src/constructs/feature/webserver/websocket/QpqApiWebserverWebsocketConstruct.ts +0 -1
- package/lib/commonjs/constructs/basic/LogStorage.d.ts +0 -22
- package/lib/commonjs/constructs/basic/LogStorage.js +0 -117
- package/lib/esm/constructs/basic/LogStorage.d.ts +0 -22
- package/lib/esm/constructs/basic/LogStorage.js +0 -86
- package/src/constructs/basic/LogStorage.ts +0 -140
|
@@ -3,7 +3,6 @@ import { Construct } from 'constructs';
|
|
|
3
3
|
import { aws_lambda, aws_iam, aws_ec2 } from 'aws-cdk-lib';
|
|
4
4
|
export interface FunctionProps extends QpqConstructBlockProps {
|
|
5
5
|
functionName?: string;
|
|
6
|
-
buildPath: string;
|
|
7
6
|
srcFilename?: string;
|
|
8
7
|
functionType: string;
|
|
9
8
|
executorName: string;
|
|
@@ -48,7 +48,7 @@ class Function extends QpqConstructBlock_1.QpqConstructBlock {
|
|
|
48
48
|
runtime: aws_cdk_lib_1.aws_lambda.Runtime.NODEJS_18_X,
|
|
49
49
|
memorySize: props.memoryInBytes || serviceInfo.lambdaMaxMemoryInMiB || 1024,
|
|
50
50
|
layers: props.apiLayerVersions,
|
|
51
|
-
code: aws_cdk_lib_1.aws_lambda.Code.fromAsset(path_1.default.join(props.
|
|
51
|
+
code: aws_cdk_lib_1.aws_lambda.Code.fromAsset(path_1.default.join(quidproquo_core_1.qpqCoreUtils.getApiBuildPathFullPath(props.qpqConfig), props.functionType)),
|
|
52
52
|
handler: `${handlerFile}.${props.executorName}`,
|
|
53
53
|
environment: Object.assign({ AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1' }, (props.environment || {})),
|
|
54
54
|
reservedConcurrentExecutions: props.reservedConcurrentExecutions,
|
|
@@ -17,6 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./Function"), exports);
|
|
18
18
|
__exportStar(require("./LambdaLayers"), exports);
|
|
19
19
|
__exportStar(require("./SubdomainName"), exports);
|
|
20
|
-
__exportStar(require("./LogStorage"), exports);
|
|
21
20
|
__exportStar(require("./ServiceDomain"), exports);
|
|
22
21
|
__exportStar(require("./InfQpqWebserverServiceDomainsConstruct"), exports);
|
|
@@ -77,7 +77,6 @@ class QpqInfCoreUserDirectoryConstruct extends QpqConstructBlock_1.QpqConstructB
|
|
|
77
77
|
props.userDirectoryConfig.emailTemplates.resetPasswordAdmin ||
|
|
78
78
|
props.userDirectoryConfig.emailTemplates.verifyEmail) {
|
|
79
79
|
const customMessageTrigger = new Function_1.Function(this, 'csm-msg-trigger-func', {
|
|
80
|
-
buildPath: quidproquo_core_1.qpqCoreUtils.getUserDirectoryEntryFullPath(props.qpqConfig, props.userDirectoryConfig),
|
|
81
80
|
functionName: this.qpqResourceName(`${props.userDirectoryConfig.name}`, 'cm-trig'),
|
|
82
81
|
functionType: 'customMessageTriggerEvent_customMessage',
|
|
83
82
|
executorName: 'customMessageTriggerEvent_customMessage',
|
|
@@ -92,7 +91,6 @@ class QpqInfCoreUserDirectoryConstruct extends QpqConstructBlock_1.QpqConstructB
|
|
|
92
91
|
}
|
|
93
92
|
if (props.userDirectoryConfig.customAuthRuntime) {
|
|
94
93
|
const defAuthChallengeTrigger = new Function_1.Function(this, 'def-auth-challenge', {
|
|
95
|
-
buildPath: quidproquo_core_1.qpqCoreUtils.getUserDirectoryEntryFullPath(props.qpqConfig, props.userDirectoryConfig),
|
|
96
94
|
functionName: this.qpqResourceName(`${props.userDirectoryConfig.name}`, 'cac-define'),
|
|
97
95
|
functionType: 'customMessageTriggerEvent_defineAuthChallenge',
|
|
98
96
|
executorName: 'customMessageTriggerEvent_defineAuthChallenge',
|
|
@@ -106,7 +104,6 @@ class QpqInfCoreUserDirectoryConstruct extends QpqConstructBlock_1.QpqConstructB
|
|
|
106
104
|
userPool.addTrigger(aws_cdk_lib_1.aws_cognito.UserPoolOperation.DEFINE_AUTH_CHALLENGE, defAuthChallengeTrigger.lambdaFunction);
|
|
107
105
|
if (props.userDirectoryConfig.customAuthRuntime.createAuthChallenge) {
|
|
108
106
|
const createAuthChallengeTrigger = new Function_1.Function(this, 'create-auth-challenge', {
|
|
109
|
-
buildPath: quidproquo_core_1.qpqCoreUtils.getUserDirectoryEntryFullPath(props.qpqConfig, props.userDirectoryConfig),
|
|
110
107
|
functionName: this.qpqResourceName(`${props.userDirectoryConfig.name}`, 'cac-create'),
|
|
111
108
|
functionType: 'customMessageTriggerEvent_createAuthChallenge',
|
|
112
109
|
executorName: 'customMessageTriggerEvent_createAuthChallenge',
|
|
@@ -121,7 +118,6 @@ class QpqInfCoreUserDirectoryConstruct extends QpqConstructBlock_1.QpqConstructB
|
|
|
121
118
|
}
|
|
122
119
|
if (props.userDirectoryConfig.customAuthRuntime.verifyAuthChallenge) {
|
|
123
120
|
const verifyAuthChallengeTrigger = new Function_1.Function(this, 'verify-auth-challenge', {
|
|
124
|
-
buildPath: quidproquo_core_1.qpqCoreUtils.getUserDirectoryEntryFullPath(props.qpqConfig, props.userDirectoryConfig),
|
|
125
121
|
functionName: this.qpqResourceName(`${props.userDirectoryConfig.name}`, 'cac-verify'),
|
|
126
122
|
functionType: 'customMessageTriggerEvent_verifyAuthChallenge',
|
|
127
123
|
executorName: 'customMessageTriggerEvent_verifyAuthChallenge',
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.QpqCoreDeployEventConstruct = void 0;
|
|
4
|
-
const quidproquo_core_1 = require("quidproquo-core");
|
|
5
4
|
const QpqConstructBlock_1 = require("../../../base/QpqConstructBlock");
|
|
6
5
|
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
7
6
|
const Function_1 = require("../../../basic/Function");
|
|
@@ -9,7 +8,6 @@ class QpqCoreDeployEventConstruct extends QpqConstructBlock_1.QpqConstructBlock
|
|
|
9
8
|
constructor(scope, id, props) {
|
|
10
9
|
super(scope, id, props);
|
|
11
10
|
const func = new Function_1.Function(this, props.deployEventConfig.uniqueKey, {
|
|
12
|
-
buildPath: quidproquo_core_1.qpqCoreUtils.getDeployEventFullPath(props.qpqConfig, props.deployEventConfig),
|
|
13
11
|
functionName: this.qpqResourceName(`${props.deployEventConfig.name}`, 'de'),
|
|
14
12
|
functionType: 'eventBridgeEvent_stackDeploy',
|
|
15
13
|
executorName: 'eventBridgeEvent_stackDeploy',
|
|
@@ -36,7 +36,6 @@ class QpqApiCoreQueueConstruct extends QpqConstructBlock_1.QpqConstructBlock {
|
|
|
36
36
|
constructor(scope, id, props) {
|
|
37
37
|
super(scope, id, props);
|
|
38
38
|
const queueFunction = new Function_1.Function(this, props.queueConfig.uniqueKey, {
|
|
39
|
-
buildPath: quidproquo_core_1.qpqCoreUtils.getQueueEntryFullPath(props.qpqConfig, props.queueConfig),
|
|
40
39
|
functionName: this.resourceName(`${props.queueConfig.uniqueKey}-queue`),
|
|
41
40
|
functionType: 'sqsEvent_queueEvent',
|
|
42
41
|
executorName: 'sqsEvent_queueEvent',
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.QpqCoreRecurringScheduleConstruct = void 0;
|
|
4
|
-
const quidproquo_core_1 = require("quidproquo-core");
|
|
5
4
|
const QpqConstructBlock_1 = require("../../../base/QpqConstructBlock");
|
|
6
5
|
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
7
6
|
const Function_1 = require("../../../basic/Function");
|
|
@@ -9,7 +8,6 @@ class QpqCoreRecurringScheduleConstruct extends QpqConstructBlock_1.QpqConstruct
|
|
|
9
8
|
constructor(scope, id, props) {
|
|
10
9
|
super(scope, id, props);
|
|
11
10
|
const schedulerFunction = new Function_1.Function(this, props.scheduleConfig.uniqueKey, {
|
|
12
|
-
buildPath: quidproquo_core_1.qpqCoreUtils.getScheduleEntryFullPath(props.qpqConfig, props.scheduleConfig),
|
|
13
11
|
functionName: this.resourceName(`${props.scheduleConfig.uniqueKey}-SE`),
|
|
14
12
|
functionType: 'eventBridgeEvent_recurringSchedule',
|
|
15
13
|
executorName: 'eventBridgeEvent_recurringSchedule',
|
package/lib/commonjs/constructs/feature/core/storageDrive/QpqApiCoreStorageDriveConstruct.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.QpqApiCoreStorageDriveConstruct = void 0;
|
|
4
|
-
const quidproquo_core_1 = require("quidproquo-core");
|
|
5
4
|
const QpqConstructBlock_1 = require("../../../base/QpqConstructBlock");
|
|
6
5
|
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
7
6
|
const QpqCoreStorageDriveConstruct_1 = require("./QpqCoreStorageDriveConstruct");
|
|
@@ -13,7 +12,6 @@ class QpqApiCoreStorageDriveConstruct extends QpqConstructBlock_1.QpqConstructBl
|
|
|
13
12
|
const bucket = QpqCoreStorageDriveConstruct_1.QpqCoreStorageDriveConstruct.fromOtherStack(scope, `bucket-${id}`, props.qpqConfig, props.storageDriveConfig, props.awsAccountId).bucket;
|
|
14
13
|
if ((_a = props.storageDriveConfig.onEvent) === null || _a === void 0 ? void 0 : _a.create) {
|
|
15
14
|
const func = new Function_1.Function(this, 'create', {
|
|
16
|
-
buildPath: quidproquo_core_1.qpqCoreUtils.getStorageDriveEntryFullPath(props.qpqConfig, props.storageDriveConfig),
|
|
17
15
|
reacreateOnFunctionNameChange: true,
|
|
18
16
|
functionName: this.qpqResourceName(props.storageDriveConfig.storageDrive, 's3Create'),
|
|
19
17
|
functionType: 's3Event_fileEvent',
|
|
@@ -32,7 +30,6 @@ class QpqApiCoreStorageDriveConstruct extends QpqConstructBlock_1.QpqConstructBl
|
|
|
32
30
|
}
|
|
33
31
|
if ((_c = props.storageDriveConfig.onEvent) === null || _c === void 0 ? void 0 : _c.delete) {
|
|
34
32
|
const func = new Function_1.Function(this, 'delete', {
|
|
35
|
-
buildPath: quidproquo_core_1.qpqCoreUtils.getStorageDriveEntryFullPath(props.qpqConfig, props.storageDriveConfig),
|
|
36
33
|
reacreateOnFunctionNameChange: true,
|
|
37
34
|
functionName: this.qpqResourceName(props.storageDriveConfig.storageDrive, 's3Delete'),
|
|
38
35
|
functionType: 's3Event_fileEvent',
|
|
@@ -17,7 +17,6 @@ class ApiQpqWebserverApiConstruct extends QpqConstructBlock_1.QpqConstructBlock
|
|
|
17
17
|
: undefined;
|
|
18
18
|
// Build Function
|
|
19
19
|
const func = new Function_1.Function(this, 'api-function', {
|
|
20
|
-
buildPath: quidproquo_webserver_1.qpqWebServerUtils.getApiEntryFullPath(props.qpqConfig, props.apiConfig),
|
|
21
20
|
functionName: this.resourceName(`${props.apiConfig.apiName}-route`),
|
|
22
21
|
functionType: 'apiGatewayEventHandler',
|
|
23
22
|
executorName: 'apiGatewayEventHandler',
|
package/lib/commonjs/constructs/feature/webserver/redirect/QpqWebserverSubdomainRedirectConstruct.js
CHANGED
|
@@ -13,7 +13,6 @@ class QpqWebserverSubdomainRedirectConstruct extends QpqConstructBlock_1.QpqCons
|
|
|
13
13
|
const environment = quidproquo_core_1.qpqCoreUtils.getApplicationModuleEnvironment(props.qpqConfig);
|
|
14
14
|
const feature = quidproquo_core_1.qpqCoreUtils.getApplicationModuleFeature(props.qpqConfig);
|
|
15
15
|
const func = new Function_1.Function(this, 'redirect', {
|
|
16
|
-
buildPath: quidproquo_webserver_1.qpqWebServerUtils.getRedirectApiBuildFullPath(props.qpqConfig, props.subdomainRedirectConfig),
|
|
17
16
|
functionName: this.resourceName(`${props.subdomainRedirectConfig.subdomain}-redirect`),
|
|
18
17
|
functionType: 'apiGatewayEventHandler_redirect',
|
|
19
18
|
executorName: 'apiGatewayEventHandler_redirect',
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.QpqWebserverServiceFunctionConstruct = void 0;
|
|
4
4
|
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
5
|
-
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
6
5
|
const QpqConstructBlock_1 = require("../../../base/QpqConstructBlock");
|
|
7
6
|
const Function_1 = require("../../../basic/Function");
|
|
8
7
|
const quidproquo_actionprocessor_awslambda_1 = require("quidproquo-actionprocessor-awslambda");
|
|
@@ -16,7 +15,6 @@ class QpqWebserverServiceFunctionConstruct extends QpqConstructBlock_1.QpqConstr
|
|
|
16
15
|
: undefined;
|
|
17
16
|
// Build Function
|
|
18
17
|
const func = new Function_1.Function(this, 'api-function', {
|
|
19
|
-
buildPath: quidproquo_webserver_1.qpqWebServerUtils.getServiceFunctionFullPath(props.qpqConfig, props.serviceFunctionConfig),
|
|
20
18
|
functionName: this.resourceName(`${props.serviceFunctionConfig.functionName}-sfunc`),
|
|
21
19
|
functionType: 'anyExecuteServiceFunctionEvent_serviceFunction',
|
|
22
20
|
executorName: 'anyExecuteServiceFunctionEvent_serviceFunction',
|
package/lib/commonjs/constructs/feature/webserver/webEntry/WebQpqWebserverWebEntryConstruct.js
CHANGED
|
@@ -37,6 +37,7 @@ const quidproquo_actionprocessor_awslambda_1 = require("quidproquo-actionprocess
|
|
|
37
37
|
const QpqConstructBlock_1 = require("../../../base/QpqConstructBlock");
|
|
38
38
|
const qpqDeployAwsCdkUtils = __importStar(require("../../../../utils"));
|
|
39
39
|
const QpqWebServerCacheConstruct_1 = require("../cache/QpqWebServerCacheConstruct");
|
|
40
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
40
41
|
class WebQpqWebserverWebEntryConstruct extends QpqConstructBlock_1.QpqConstructBlock {
|
|
41
42
|
constructor(scope, id, props) {
|
|
42
43
|
super(scope, id, props);
|
|
@@ -175,7 +176,7 @@ class WebQpqWebserverWebEntryConstruct extends QpqConstructBlock_1.QpqConstructB
|
|
|
175
176
|
const seos = quidproquo_webserver_1.qpqWebServerUtils.getAllSeo(props.qpqConfig).filter((seo) => !seo.webEntry || seo.webEntry === props.webEntryConfig.name);
|
|
176
177
|
// if we have some ~ Build the edge lambdas and deploy
|
|
177
178
|
if (seos.length > 0) {
|
|
178
|
-
const seoEntryBuildPath =
|
|
179
|
+
const seoEntryBuildPath = quidproquo_core_1.qpqCoreUtils.getApiBuildPathFullPath(props.qpqConfig);
|
|
179
180
|
const edgeFunctionVR = new aws_cdk_lib_1.aws_cloudfront.experimental.EdgeFunction(this, `SEO-VR`, {
|
|
180
181
|
functionName: this.qpqResourceName(props.webEntryConfig.name, 'SEO-VR'),
|
|
181
182
|
timeout: cdk.Duration.seconds(5),
|
package/lib/commonjs/constructs/feature/webserver/websocket/QpqApiWebserverWebsocketConstruct.js
CHANGED
|
@@ -23,7 +23,6 @@ class QpqApiWebserverWebsocketConstruct extends QpqConstructBlock_1.QpqConstruct
|
|
|
23
23
|
stageName: 'prod',
|
|
24
24
|
});
|
|
25
25
|
const func = new Function_1.Function(this, 'api-function', {
|
|
26
|
-
buildPath: quidproquo_webserver_1.qpqWebServerUtils.getWebsocketEntryFullPath(props.qpqConfig, props.websocketConfig),
|
|
27
26
|
functionName: this.resourceName(`${props.websocketConfig.apiName}-ws`),
|
|
28
27
|
functionType: 'apiGatwayEventWebsocketWithIdentity_websocketEvent',
|
|
29
28
|
executorName: 'apiGatwayEventWebsocketWithIdentity_websocketEvent',
|
|
@@ -3,7 +3,6 @@ import { Construct } from 'constructs';
|
|
|
3
3
|
import { aws_lambda, aws_iam, aws_ec2 } from 'aws-cdk-lib';
|
|
4
4
|
export interface FunctionProps extends QpqConstructBlockProps {
|
|
5
5
|
functionName?: string;
|
|
6
|
-
buildPath: string;
|
|
7
6
|
srcFilename?: string;
|
|
8
7
|
functionType: string;
|
|
9
8
|
executorName: string;
|
|
@@ -19,7 +19,7 @@ export class Function extends QpqConstructBlock {
|
|
|
19
19
|
runtime: aws_lambda.Runtime.NODEJS_18_X,
|
|
20
20
|
memorySize: props.memoryInBytes || serviceInfo.lambdaMaxMemoryInMiB || 1024,
|
|
21
21
|
layers: props.apiLayerVersions,
|
|
22
|
-
code: aws_lambda.Code.fromAsset(path.join(props.
|
|
22
|
+
code: aws_lambda.Code.fromAsset(path.join(qpqCoreUtils.getApiBuildPathFullPath(props.qpqConfig), props.functionType)),
|
|
23
23
|
handler: `${handlerFile}.${props.executorName}`,
|
|
24
24
|
environment: {
|
|
25
25
|
AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1',
|
|
@@ -48,7 +48,6 @@ export class QpqInfCoreUserDirectoryConstruct extends QpqConstructBlock {
|
|
|
48
48
|
props.userDirectoryConfig.emailTemplates.resetPasswordAdmin ||
|
|
49
49
|
props.userDirectoryConfig.emailTemplates.verifyEmail) {
|
|
50
50
|
const customMessageTrigger = new Function(this, 'csm-msg-trigger-func', {
|
|
51
|
-
buildPath: qpqCoreUtils.getUserDirectoryEntryFullPath(props.qpqConfig, props.userDirectoryConfig),
|
|
52
51
|
functionName: this.qpqResourceName(`${props.userDirectoryConfig.name}`, 'cm-trig'),
|
|
53
52
|
functionType: 'customMessageTriggerEvent_customMessage',
|
|
54
53
|
executorName: 'customMessageTriggerEvent_customMessage',
|
|
@@ -63,7 +62,6 @@ export class QpqInfCoreUserDirectoryConstruct extends QpqConstructBlock {
|
|
|
63
62
|
}
|
|
64
63
|
if (props.userDirectoryConfig.customAuthRuntime) {
|
|
65
64
|
const defAuthChallengeTrigger = new Function(this, 'def-auth-challenge', {
|
|
66
|
-
buildPath: qpqCoreUtils.getUserDirectoryEntryFullPath(props.qpqConfig, props.userDirectoryConfig),
|
|
67
65
|
functionName: this.qpqResourceName(`${props.userDirectoryConfig.name}`, 'cac-define'),
|
|
68
66
|
functionType: 'customMessageTriggerEvent_defineAuthChallenge',
|
|
69
67
|
executorName: 'customMessageTriggerEvent_defineAuthChallenge',
|
|
@@ -77,7 +75,6 @@ export class QpqInfCoreUserDirectoryConstruct extends QpqConstructBlock {
|
|
|
77
75
|
userPool.addTrigger(aws_cognito.UserPoolOperation.DEFINE_AUTH_CHALLENGE, defAuthChallengeTrigger.lambdaFunction);
|
|
78
76
|
if (props.userDirectoryConfig.customAuthRuntime.createAuthChallenge) {
|
|
79
77
|
const createAuthChallengeTrigger = new Function(this, 'create-auth-challenge', {
|
|
80
|
-
buildPath: qpqCoreUtils.getUserDirectoryEntryFullPath(props.qpqConfig, props.userDirectoryConfig),
|
|
81
78
|
functionName: this.qpqResourceName(`${props.userDirectoryConfig.name}`, 'cac-create'),
|
|
82
79
|
functionType: 'customMessageTriggerEvent_createAuthChallenge',
|
|
83
80
|
executorName: 'customMessageTriggerEvent_createAuthChallenge',
|
|
@@ -92,7 +89,6 @@ export class QpqInfCoreUserDirectoryConstruct extends QpqConstructBlock {
|
|
|
92
89
|
}
|
|
93
90
|
if (props.userDirectoryConfig.customAuthRuntime.verifyAuthChallenge) {
|
|
94
91
|
const verifyAuthChallengeTrigger = new Function(this, 'verify-auth-challenge', {
|
|
95
|
-
buildPath: qpqCoreUtils.getUserDirectoryEntryFullPath(props.qpqConfig, props.userDirectoryConfig),
|
|
96
92
|
functionName: this.qpqResourceName(`${props.userDirectoryConfig.name}`, 'cac-verify'),
|
|
97
93
|
functionType: 'customMessageTriggerEvent_verifyAuthChallenge',
|
|
98
94
|
executorName: 'customMessageTriggerEvent_verifyAuthChallenge',
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { qpqCoreUtils } from 'quidproquo-core';
|
|
2
1
|
import { QpqConstructBlock } from '../../../base/QpqConstructBlock';
|
|
3
2
|
import { aws_events, aws_events_targets } from 'aws-cdk-lib';
|
|
4
3
|
import { Function } from '../../../basic/Function';
|
|
@@ -6,7 +5,6 @@ export class QpqCoreDeployEventConstruct extends QpqConstructBlock {
|
|
|
6
5
|
constructor(scope, id, props) {
|
|
7
6
|
super(scope, id, props);
|
|
8
7
|
const func = new Function(this, props.deployEventConfig.uniqueKey, {
|
|
9
|
-
buildPath: qpqCoreUtils.getDeployEventFullPath(props.qpqConfig, props.deployEventConfig),
|
|
10
8
|
functionName: this.qpqResourceName(`${props.deployEventConfig.name}`, 'de'),
|
|
11
9
|
functionType: 'eventBridgeEvent_stackDeploy',
|
|
12
10
|
executorName: 'eventBridgeEvent_stackDeploy',
|
|
@@ -10,7 +10,6 @@ export class QpqApiCoreQueueConstruct extends QpqConstructBlock {
|
|
|
10
10
|
constructor(scope, id, props) {
|
|
11
11
|
super(scope, id, props);
|
|
12
12
|
const queueFunction = new Function(this, props.queueConfig.uniqueKey, {
|
|
13
|
-
buildPath: qpqCoreUtils.getQueueEntryFullPath(props.qpqConfig, props.queueConfig),
|
|
14
13
|
functionName: this.resourceName(`${props.queueConfig.uniqueKey}-queue`),
|
|
15
14
|
functionType: 'sqsEvent_queueEvent',
|
|
16
15
|
executorName: 'sqsEvent_queueEvent',
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { qpqCoreUtils } from 'quidproquo-core';
|
|
2
1
|
import { QpqConstructBlock } from '../../../base/QpqConstructBlock';
|
|
3
2
|
import { aws_events, aws_events_targets } from 'aws-cdk-lib';
|
|
4
3
|
import { Function } from '../../../basic/Function';
|
|
@@ -6,7 +5,6 @@ export class QpqCoreRecurringScheduleConstruct extends QpqConstructBlock {
|
|
|
6
5
|
constructor(scope, id, props) {
|
|
7
6
|
super(scope, id, props);
|
|
8
7
|
const schedulerFunction = new Function(this, props.scheduleConfig.uniqueKey, {
|
|
9
|
-
buildPath: qpqCoreUtils.getScheduleEntryFullPath(props.qpqConfig, props.scheduleConfig),
|
|
10
8
|
functionName: this.resourceName(`${props.scheduleConfig.uniqueKey}-SE`),
|
|
11
9
|
functionType: 'eventBridgeEvent_recurringSchedule',
|
|
12
10
|
executorName: 'eventBridgeEvent_recurringSchedule',
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { qpqCoreUtils } from 'quidproquo-core';
|
|
2
1
|
import { QpqConstructBlock } from '../../../base/QpqConstructBlock';
|
|
3
2
|
import { aws_s3, aws_s3_notifications } from 'aws-cdk-lib';
|
|
4
3
|
import { QpqCoreStorageDriveConstruct } from './QpqCoreStorageDriveConstruct';
|
|
@@ -9,7 +8,6 @@ export class QpqApiCoreStorageDriveConstruct extends QpqConstructBlock {
|
|
|
9
8
|
const bucket = QpqCoreStorageDriveConstruct.fromOtherStack(scope, `bucket-${id}`, props.qpqConfig, props.storageDriveConfig, props.awsAccountId).bucket;
|
|
10
9
|
if (props.storageDriveConfig.onEvent?.create) {
|
|
11
10
|
const func = new Function(this, 'create', {
|
|
12
|
-
buildPath: qpqCoreUtils.getStorageDriveEntryFullPath(props.qpqConfig, props.storageDriveConfig),
|
|
13
11
|
reacreateOnFunctionNameChange: true,
|
|
14
12
|
functionName: this.qpqResourceName(props.storageDriveConfig.storageDrive, 's3Create'),
|
|
15
13
|
functionType: 's3Event_fileEvent',
|
|
@@ -28,7 +26,6 @@ export class QpqApiCoreStorageDriveConstruct extends QpqConstructBlock {
|
|
|
28
26
|
}
|
|
29
27
|
if (props.storageDriveConfig.onEvent?.delete) {
|
|
30
28
|
const func = new Function(this, 'delete', {
|
|
31
|
-
buildPath: qpqCoreUtils.getStorageDriveEntryFullPath(props.qpqConfig, props.storageDriveConfig),
|
|
32
29
|
reacreateOnFunctionNameChange: true,
|
|
33
30
|
functionName: this.qpqResourceName(props.storageDriveConfig.storageDrive, 's3Delete'),
|
|
34
31
|
functionType: 's3Event_fileEvent',
|
|
@@ -14,7 +14,6 @@ export class ApiQpqWebserverApiConstruct extends QpqConstructBlock {
|
|
|
14
14
|
: undefined;
|
|
15
15
|
// Build Function
|
|
16
16
|
const func = new Function(this, 'api-function', {
|
|
17
|
-
buildPath: qpqWebServerUtils.getApiEntryFullPath(props.qpqConfig, props.apiConfig),
|
|
18
17
|
functionName: this.resourceName(`${props.apiConfig.apiName}-route`),
|
|
19
18
|
functionType: 'apiGatewayEventHandler',
|
|
20
19
|
executorName: 'apiGatewayEventHandler',
|
package/lib/esm/constructs/feature/webserver/redirect/QpqWebserverSubdomainRedirectConstruct.js
CHANGED
|
@@ -10,7 +10,6 @@ export class QpqWebserverSubdomainRedirectConstruct extends QpqConstructBlock {
|
|
|
10
10
|
const environment = qpqCoreUtils.getApplicationModuleEnvironment(props.qpqConfig);
|
|
11
11
|
const feature = qpqCoreUtils.getApplicationModuleFeature(props.qpqConfig);
|
|
12
12
|
const func = new Function(this, 'redirect', {
|
|
13
|
-
buildPath: qpqWebServerUtils.getRedirectApiBuildFullPath(props.qpqConfig, props.subdomainRedirectConfig),
|
|
14
13
|
functionName: this.resourceName(`${props.subdomainRedirectConfig.subdomain}-redirect`),
|
|
15
14
|
functionType: 'apiGatewayEventHandler_redirect',
|
|
16
15
|
executorName: 'apiGatewayEventHandler_redirect',
|
package/lib/esm/constructs/feature/webserver/serviceFunction/QpqWebserverServiceFunctionConstruct.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { aws_ec2 } from 'aws-cdk-lib';
|
|
2
|
-
import { qpqWebServerUtils } from 'quidproquo-webserver';
|
|
3
2
|
import { QpqConstructBlock } from '../../../base/QpqConstructBlock';
|
|
4
3
|
import { Function } from '../../../basic/Function';
|
|
5
4
|
import { awsNamingUtils } from 'quidproquo-actionprocessor-awslambda';
|
|
@@ -13,7 +12,6 @@ export class QpqWebserverServiceFunctionConstruct extends QpqConstructBlock {
|
|
|
13
12
|
: undefined;
|
|
14
13
|
// Build Function
|
|
15
14
|
const func = new Function(this, 'api-function', {
|
|
16
|
-
buildPath: qpqWebServerUtils.getServiceFunctionFullPath(props.qpqConfig, props.serviceFunctionConfig),
|
|
17
15
|
functionName: this.resourceName(`${props.serviceFunctionConfig.functionName}-sfunc`),
|
|
18
16
|
functionType: 'anyExecuteServiceFunctionEvent_serviceFunction',
|
|
19
17
|
executorName: 'anyExecuteServiceFunctionEvent_serviceFunction',
|
|
@@ -8,6 +8,7 @@ import { awsNamingUtils } from 'quidproquo-actionprocessor-awslambda';
|
|
|
8
8
|
import { QpqConstructBlock } from '../../../base/QpqConstructBlock';
|
|
9
9
|
import * as qpqDeployAwsCdkUtils from '../../../../utils';
|
|
10
10
|
import { QpqWebServerCacheConstruct } from '../cache/QpqWebServerCacheConstruct';
|
|
11
|
+
import { qpqCoreUtils } from 'quidproquo-core';
|
|
11
12
|
export class WebQpqWebserverWebEntryConstruct extends QpqConstructBlock {
|
|
12
13
|
constructor(scope, id, props) {
|
|
13
14
|
super(scope, id, props);
|
|
@@ -146,7 +147,7 @@ export class WebQpqWebserverWebEntryConstruct extends QpqConstructBlock {
|
|
|
146
147
|
const seos = qpqWebServerUtils.getAllSeo(props.qpqConfig).filter((seo) => !seo.webEntry || seo.webEntry === props.webEntryConfig.name);
|
|
147
148
|
// if we have some ~ Build the edge lambdas and deploy
|
|
148
149
|
if (seos.length > 0) {
|
|
149
|
-
const seoEntryBuildPath =
|
|
150
|
+
const seoEntryBuildPath = qpqCoreUtils.getApiBuildPathFullPath(props.qpqConfig);
|
|
150
151
|
const edgeFunctionVR = new aws_cloudfront.experimental.EdgeFunction(this, `SEO-VR`, {
|
|
151
152
|
functionName: this.qpqResourceName(props.webEntryConfig.name, 'SEO-VR'),
|
|
152
153
|
timeout: cdk.Duration.seconds(5),
|
|
@@ -20,7 +20,6 @@ export class QpqApiWebserverWebsocketConstruct extends QpqConstructBlock {
|
|
|
20
20
|
stageName: 'prod',
|
|
21
21
|
});
|
|
22
22
|
const func = new Function(this, 'api-function', {
|
|
23
|
-
buildPath: qpqWebServerUtils.getWebsocketEntryFullPath(props.qpqConfig, props.websocketConfig),
|
|
24
23
|
functionName: this.resourceName(`${props.websocketConfig.apiName}-ws`),
|
|
25
24
|
functionType: 'apiGatwayEventWebsocketWithIdentity_websocketEvent',
|
|
26
25
|
executorName: 'apiGatwayEventWebsocketWithIdentity_websocketEvent',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quidproquo-deploy-awscdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.232",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -36,18 +36,18 @@
|
|
|
36
36
|
"constructs": "^10.1.208",
|
|
37
37
|
"esbuild": "^0.15.16",
|
|
38
38
|
"liquidjs": "^10.7.0",
|
|
39
|
-
"quidproquo-actionprocessor-awslambda": "0.0.
|
|
40
|
-
"quidproquo-actionprocessor-node": "0.0.
|
|
41
|
-
"quidproquo-config-aws": "0.0.
|
|
42
|
-
"quidproquo-core": "0.0.
|
|
43
|
-
"quidproquo-webserver": "0.0.
|
|
39
|
+
"quidproquo-actionprocessor-awslambda": "0.0.232",
|
|
40
|
+
"quidproquo-actionprocessor-node": "0.0.232",
|
|
41
|
+
"quidproquo-config-aws": "0.0.232",
|
|
42
|
+
"quidproquo-core": "0.0.232",
|
|
43
|
+
"quidproquo-webserver": "0.0.232"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/aws-lambda": "^8.10.109",
|
|
47
47
|
"@types/babel__traverse": "7.18.2",
|
|
48
48
|
"@types/node": "^20.2.1",
|
|
49
49
|
"@types/prettier": "2.6.0",
|
|
50
|
-
"quidproquo-tsconfig": "0.0.
|
|
50
|
+
"quidproquo-tsconfig": "0.0.232",
|
|
51
51
|
"ts-node": "^10.9.1",
|
|
52
52
|
"typescript": "^4.9.3"
|
|
53
53
|
}
|
|
@@ -13,7 +13,6 @@ import { qpqCoreUtils } from 'quidproquo-core';
|
|
|
13
13
|
export interface FunctionProps extends QpqConstructBlockProps {
|
|
14
14
|
functionName?: string;
|
|
15
15
|
|
|
16
|
-
buildPath: string;
|
|
17
16
|
srcFilename?: string;
|
|
18
17
|
functionType: string; // TODO: Rename this to subFolder / folder or something
|
|
19
18
|
executorName: string; // TODO: Rename this to handlerName or something maybe?
|
|
@@ -58,7 +57,7 @@ export class Function extends QpqConstructBlock {
|
|
|
58
57
|
memorySize: props.memoryInBytes || serviceInfo.lambdaMaxMemoryInMiB || 1024,
|
|
59
58
|
layers: props.apiLayerVersions,
|
|
60
59
|
|
|
61
|
-
code: aws_lambda.Code.fromAsset(path.join(props.
|
|
60
|
+
code: aws_lambda.Code.fromAsset(path.join(qpqCoreUtils.getApiBuildPathFullPath(props.qpqConfig), props.functionType)),
|
|
62
61
|
handler: `${handlerFile}.${props.executorName}`,
|
|
63
62
|
|
|
64
63
|
environment: {
|
|
@@ -76,7 +76,6 @@ export class QpqInfCoreUserDirectoryConstruct extends QpqConstructBlock {
|
|
|
76
76
|
props.userDirectoryConfig.emailTemplates.verifyEmail
|
|
77
77
|
) {
|
|
78
78
|
const customMessageTrigger = new Function(this, 'csm-msg-trigger-func', {
|
|
79
|
-
buildPath: qpqCoreUtils.getUserDirectoryEntryFullPath(props.qpqConfig, props.userDirectoryConfig),
|
|
80
79
|
functionName: this.qpqResourceName(`${props.userDirectoryConfig.name}`, 'cm-trig'),
|
|
81
80
|
functionType: 'customMessageTriggerEvent_customMessage',
|
|
82
81
|
executorName: 'customMessageTriggerEvent_customMessage',
|
|
@@ -97,7 +96,6 @@ export class QpqInfCoreUserDirectoryConstruct extends QpqConstructBlock {
|
|
|
97
96
|
|
|
98
97
|
if (props.userDirectoryConfig.customAuthRuntime) {
|
|
99
98
|
const defAuthChallengeTrigger = new Function(this, 'def-auth-challenge', {
|
|
100
|
-
buildPath: qpqCoreUtils.getUserDirectoryEntryFullPath(props.qpqConfig, props.userDirectoryConfig),
|
|
101
99
|
functionName: this.qpqResourceName(`${props.userDirectoryConfig.name}`, 'cac-define'),
|
|
102
100
|
functionType: 'customMessageTriggerEvent_defineAuthChallenge',
|
|
103
101
|
executorName: 'customMessageTriggerEvent_defineAuthChallenge',
|
|
@@ -117,7 +115,6 @@ export class QpqInfCoreUserDirectoryConstruct extends QpqConstructBlock {
|
|
|
117
115
|
|
|
118
116
|
if (props.userDirectoryConfig.customAuthRuntime.createAuthChallenge) {
|
|
119
117
|
const createAuthChallengeTrigger = new Function(this, 'create-auth-challenge', {
|
|
120
|
-
buildPath: qpqCoreUtils.getUserDirectoryEntryFullPath(props.qpqConfig, props.userDirectoryConfig),
|
|
121
118
|
functionName: this.qpqResourceName(`${props.userDirectoryConfig.name}`, 'cac-create'),
|
|
122
119
|
functionType: 'customMessageTriggerEvent_createAuthChallenge',
|
|
123
120
|
executorName: 'customMessageTriggerEvent_createAuthChallenge',
|
|
@@ -137,7 +134,6 @@ export class QpqInfCoreUserDirectoryConstruct extends QpqConstructBlock {
|
|
|
137
134
|
|
|
138
135
|
if (props.userDirectoryConfig.customAuthRuntime.verifyAuthChallenge) {
|
|
139
136
|
const verifyAuthChallengeTrigger = new Function(this, 'verify-auth-challenge', {
|
|
140
|
-
buildPath: qpqCoreUtils.getUserDirectoryEntryFullPath(props.qpqConfig, props.userDirectoryConfig),
|
|
141
137
|
functionName: this.qpqResourceName(`${props.userDirectoryConfig.name}`, 'cac-verify'),
|
|
142
138
|
functionType: 'customMessageTriggerEvent_verifyAuthChallenge',
|
|
143
139
|
executorName: 'customMessageTriggerEvent_verifyAuthChallenge',
|
|
@@ -18,7 +18,6 @@ export class QpqCoreDeployEventConstruct extends QpqConstructBlock {
|
|
|
18
18
|
super(scope, id, props);
|
|
19
19
|
|
|
20
20
|
const func = new Function(this, props.deployEventConfig.uniqueKey, {
|
|
21
|
-
buildPath: qpqCoreUtils.getDeployEventFullPath(props.qpqConfig, props.deployEventConfig),
|
|
22
21
|
functionName: this.qpqResourceName(`${props.deployEventConfig.name}`, 'de'),
|
|
23
22
|
functionType: 'eventBridgeEvent_stackDeploy',
|
|
24
23
|
executorName: 'eventBridgeEvent_stackDeploy',
|
|
@@ -21,7 +21,6 @@ export class QpqApiCoreQueueConstruct extends QpqConstructBlock {
|
|
|
21
21
|
super(scope, id, props);
|
|
22
22
|
|
|
23
23
|
const queueFunction = new Function(this, props.queueConfig.uniqueKey, {
|
|
24
|
-
buildPath: qpqCoreUtils.getQueueEntryFullPath(props.qpqConfig, props.queueConfig),
|
|
25
24
|
functionName: this.resourceName(`${props.queueConfig.uniqueKey}-queue`),
|
|
26
25
|
functionType: 'sqsEvent_queueEvent',
|
|
27
26
|
executorName: 'sqsEvent_queueEvent',
|
|
@@ -18,7 +18,6 @@ export class QpqCoreRecurringScheduleConstruct extends QpqConstructBlock {
|
|
|
18
18
|
super(scope, id, props);
|
|
19
19
|
|
|
20
20
|
const schedulerFunction = new Function(this, props.scheduleConfig.uniqueKey, {
|
|
21
|
-
buildPath: qpqCoreUtils.getScheduleEntryFullPath(props.qpqConfig, props.scheduleConfig),
|
|
22
21
|
functionName: this.resourceName(`${props.scheduleConfig.uniqueKey}-SE`),
|
|
23
22
|
functionType: 'eventBridgeEvent_recurringSchedule',
|
|
24
23
|
executorName: 'eventBridgeEvent_recurringSchedule',
|
|
@@ -26,8 +26,6 @@ export class QpqApiCoreStorageDriveConstruct extends QpqConstructBlock {
|
|
|
26
26
|
|
|
27
27
|
if (props.storageDriveConfig.onEvent?.create) {
|
|
28
28
|
const func = new Function(this, 'create', {
|
|
29
|
-
buildPath: qpqCoreUtils.getStorageDriveEntryFullPath(props.qpqConfig, props.storageDriveConfig),
|
|
30
|
-
|
|
31
29
|
reacreateOnFunctionNameChange: true,
|
|
32
30
|
functionName: this.qpqResourceName(props.storageDriveConfig.storageDrive, 's3Create'),
|
|
33
31
|
|
|
@@ -54,8 +52,6 @@ export class QpqApiCoreStorageDriveConstruct extends QpqConstructBlock {
|
|
|
54
52
|
|
|
55
53
|
if (props.storageDriveConfig.onEvent?.delete) {
|
|
56
54
|
const func = new Function(this, 'delete', {
|
|
57
|
-
buildPath: qpqCoreUtils.getStorageDriveEntryFullPath(props.qpqConfig, props.storageDriveConfig),
|
|
58
|
-
|
|
59
55
|
reacreateOnFunctionNameChange: true,
|
|
60
56
|
functionName: this.qpqResourceName(props.storageDriveConfig.storageDrive, 's3Delete'),
|
|
61
57
|
|
|
@@ -28,7 +28,6 @@ export class ApiQpqWebserverApiConstruct extends QpqConstructBlock {
|
|
|
28
28
|
|
|
29
29
|
// Build Function
|
|
30
30
|
const func = new Function(this, 'api-function', {
|
|
31
|
-
buildPath: qpqWebServerUtils.getApiEntryFullPath(props.qpqConfig, props.apiConfig),
|
|
32
31
|
functionName: this.resourceName(`${props.apiConfig.apiName}-route`),
|
|
33
32
|
functionType: 'apiGatewayEventHandler',
|
|
34
33
|
executorName: 'apiGatewayEventHandler',
|
|
@@ -25,7 +25,6 @@ export class QpqWebserverSubdomainRedirectConstruct extends QpqConstructBlock {
|
|
|
25
25
|
const feature = qpqCoreUtils.getApplicationModuleFeature(props.qpqConfig);
|
|
26
26
|
|
|
27
27
|
const func = new Function(this, 'redirect', {
|
|
28
|
-
buildPath: qpqWebServerUtils.getRedirectApiBuildFullPath(props.qpqConfig, props.subdomainRedirectConfig),
|
|
29
28
|
functionName: this.resourceName(`${props.subdomainRedirectConfig.subdomain}-redirect`),
|
|
30
29
|
functionType: 'apiGatewayEventHandler_redirect',
|
|
31
30
|
executorName: 'apiGatewayEventHandler_redirect',
|
package/src/constructs/feature/webserver/serviceFunction/QpqWebserverServiceFunctionConstruct.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { aws_ec2, aws_lambda } from 'aws-cdk-lib';
|
|
2
2
|
import { Construct } from 'constructs';
|
|
3
3
|
|
|
4
|
-
import { ServiceFunctionQPQWebServerConfigSetting
|
|
4
|
+
import { ServiceFunctionQPQWebServerConfigSetting } from 'quidproquo-webserver';
|
|
5
5
|
|
|
6
6
|
import { QpqConstructBlock, QpqConstructBlockProps } from '../../../base/QpqConstructBlock';
|
|
7
7
|
|
|
8
8
|
import { Function } from '../../../basic/Function';
|
|
9
9
|
import { awsNamingUtils } from 'quidproquo-actionprocessor-awslambda';
|
|
10
|
+
import { qpqCoreUtils } from 'quidproquo-core';
|
|
10
11
|
|
|
11
12
|
export interface QpqWebserverServiceFunctionConstructProps extends QpqConstructBlockProps {
|
|
12
13
|
serviceFunctionConfig: ServiceFunctionQPQWebServerConfigSetting;
|
|
@@ -25,7 +26,6 @@ export class QpqWebserverServiceFunctionConstruct extends QpqConstructBlock {
|
|
|
25
26
|
|
|
26
27
|
// Build Function
|
|
27
28
|
const func = new Function(this, 'api-function', {
|
|
28
|
-
buildPath: qpqWebServerUtils.getServiceFunctionFullPath(props.qpqConfig, props.serviceFunctionConfig),
|
|
29
29
|
functionName: this.resourceName(`${props.serviceFunctionConfig.functionName}-sfunc`),
|
|
30
30
|
functionType: 'anyExecuteServiceFunctionEvent_serviceFunction',
|
|
31
31
|
executorName: 'anyExecuteServiceFunctionEvent_serviceFunction',
|
|
@@ -25,6 +25,7 @@ import { Construct } from 'constructs';
|
|
|
25
25
|
|
|
26
26
|
import * as qpqDeployAwsCdkUtils from '../../../../utils';
|
|
27
27
|
import { QpqWebServerCacheConstruct } from '../cache/QpqWebServerCacheConstruct';
|
|
28
|
+
import { qpqCoreUtils } from 'quidproquo-core';
|
|
28
29
|
|
|
29
30
|
export interface WebQpqWebserverWebEntryConstructProps extends QpqConstructBlockProps {
|
|
30
31
|
webEntryConfig: WebEntryQPQWebServerConfigSetting;
|
|
@@ -210,7 +211,7 @@ export class WebQpqWebserverWebEntryConstruct extends QpqConstructBlock {
|
|
|
210
211
|
|
|
211
212
|
// if we have some ~ Build the edge lambdas and deploy
|
|
212
213
|
if (seos.length > 0) {
|
|
213
|
-
const seoEntryBuildPath =
|
|
214
|
+
const seoEntryBuildPath = qpqCoreUtils.getApiBuildPathFullPath(props.qpqConfig);
|
|
214
215
|
|
|
215
216
|
const edgeFunctionVR = new aws_cloudfront.experimental.EdgeFunction(this, `SEO-VR`, {
|
|
216
217
|
functionName: this.qpqResourceName(props.webEntryConfig.name, 'SEO-VR'),
|
|
@@ -35,7 +35,6 @@ export class QpqApiWebserverWebsocketConstruct extends QpqConstructBlock {
|
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
const func = new Function(this, 'api-function', {
|
|
38
|
-
buildPath: qpqWebServerUtils.getWebsocketEntryFullPath(props.qpqConfig, props.websocketConfig),
|
|
39
38
|
functionName: this.resourceName(`${props.websocketConfig.apiName}-ws`),
|
|
40
39
|
functionType: 'apiGatwayEventWebsocketWithIdentity_websocketEvent',
|
|
41
40
|
executorName: 'apiGatwayEventWebsocketWithIdentity_websocketEvent',
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { QPQConfig } from 'quidproquo-core';
|
|
2
|
-
import { Construct } from 'constructs';
|
|
3
|
-
import { aws_s3, aws_iam, aws_dynamodb } from 'aws-cdk-lib';
|
|
4
|
-
import { QpqConstructBlock, QpqConstructBlockProps } from '../base/QpqConstructBlock';
|
|
5
|
-
import { QpqResource } from '../base';
|
|
6
|
-
export interface LogStorageProps extends QpqConstructBlockProps {
|
|
7
|
-
}
|
|
8
|
-
export declare abstract class LogStorageConstructBase extends QpqConstructBlock implements QpqResource {
|
|
9
|
-
abstract bucket: aws_s3.IBucket;
|
|
10
|
-
abstract storyResultsTable: aws_dynamodb.ITable;
|
|
11
|
-
abstract fromStoryResultsTable: aws_dynamodb.ITable;
|
|
12
|
-
grantRead(grantee: aws_iam.IGrantable): void;
|
|
13
|
-
grantWrite(grantee: aws_iam.IGrantable): void;
|
|
14
|
-
grantAll(grantee: aws_iam.IGrantable): void;
|
|
15
|
-
}
|
|
16
|
-
export declare class LogStorage extends QpqConstructBlock {
|
|
17
|
-
readonly bucket: aws_s3.IBucket;
|
|
18
|
-
readonly storyResultsTable: aws_dynamodb.ITable;
|
|
19
|
-
readonly fromStoryResultsTable: aws_dynamodb.ITable;
|
|
20
|
-
static fromOtherStack(scope: Construct, id: string, qpqConfig: QPQConfig, awsAccountId: string, serviceBucketName: string): QpqResource;
|
|
21
|
-
constructor(scope: Construct, id: string, props: LogStorageProps);
|
|
22
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.LogStorage = exports.LogStorageConstructBase = void 0;
|
|
30
|
-
const path_1 = __importDefault(require("path"));
|
|
31
|
-
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
32
|
-
const cdk = __importStar(require("aws-cdk-lib"));
|
|
33
|
-
const QpqConstructBlock_1 = require("../base/QpqConstructBlock");
|
|
34
|
-
const constants_1 = require("../../constants");
|
|
35
|
-
const Function_1 = require("./Function");
|
|
36
|
-
class LogStorageConstructBase extends QpqConstructBlock_1.QpqConstructBlock {
|
|
37
|
-
grantRead(grantee) {
|
|
38
|
-
this.storyResultsTable.grantReadData(grantee);
|
|
39
|
-
this.fromStoryResultsTable.grantReadData(grantee);
|
|
40
|
-
this.bucket.grantRead(grantee);
|
|
41
|
-
}
|
|
42
|
-
grantWrite(grantee) {
|
|
43
|
-
this.storyResultsTable.grantWriteData(grantee);
|
|
44
|
-
this.fromStoryResultsTable.grantWriteData(grantee);
|
|
45
|
-
this.bucket.grantWrite(grantee);
|
|
46
|
-
}
|
|
47
|
-
grantAll(grantee) {
|
|
48
|
-
this.grantRead(grantee);
|
|
49
|
-
this.grantWrite(grantee);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
exports.LogStorageConstructBase = LogStorageConstructBase;
|
|
53
|
-
class LogStorage extends QpqConstructBlock_1.QpqConstructBlock {
|
|
54
|
-
static fromOtherStack(scope, id, qpqConfig, awsAccountId, serviceBucketName) {
|
|
55
|
-
class Import extends LogStorageConstructBase {
|
|
56
|
-
constructor() {
|
|
57
|
-
super(...arguments);
|
|
58
|
-
this.bucket = aws_cdk_lib_1.aws_s3.Bucket.fromBucketName(scope, `${id}-log-storage`, this.qpqResourceName(serviceBucketName, 'log'));
|
|
59
|
-
this.storyResultsTable = aws_cdk_lib_1.aws_dynamodb.Table.fromTableName(scope, `${id}-log-table`, this.qpqResourceName(serviceBucketName, 'log'));
|
|
60
|
-
this.fromStoryResultsTable = aws_cdk_lib_1.aws_dynamodb.Table.fromTableName(scope, `${id}-flog-table`, this.qpqResourceName(serviceBucketName, 'flog'));
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return new Import(scope, id, { qpqConfig, awsAccountId });
|
|
64
|
-
}
|
|
65
|
-
constructor(scope, id, props) {
|
|
66
|
-
super(scope, id, props);
|
|
67
|
-
this.bucket = new aws_cdk_lib_1.aws_s3.Bucket(this, 'bucket', {
|
|
68
|
-
bucketName: this.qpqResourceName(constants_1.QPQ_LOG_BUCKET_NAME, 'log'),
|
|
69
|
-
// Disable public access to this bucket
|
|
70
|
-
publicReadAccess: false,
|
|
71
|
-
blockPublicAccess: aws_cdk_lib_1.aws_s3.BlockPublicAccess.BLOCK_ALL,
|
|
72
|
-
// Allow bucket to auto delete upon cdk:Destroy
|
|
73
|
-
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
74
|
-
autoDeleteObjects: true,
|
|
75
|
-
});
|
|
76
|
-
// Time based query over all logs for a given runtimeType
|
|
77
|
-
const storyResultsTable = new aws_cdk_lib_1.aws_dynamodb.Table(this, 'table', {
|
|
78
|
-
tableName: this.qpqResourceName(constants_1.QPQ_LOG_BUCKET_NAME, 'log'),
|
|
79
|
-
partitionKey: { name: 'runtimeType', type: aws_cdk_lib_1.aws_dynamodb.AttributeType.STRING },
|
|
80
|
-
sortKey: { name: 'startedAtWithCorrelation', type: aws_cdk_lib_1.aws_dynamodb.AttributeType.STRING },
|
|
81
|
-
billingMode: aws_cdk_lib_1.aws_dynamodb.BillingMode.PAY_PER_REQUEST,
|
|
82
|
-
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
83
|
-
});
|
|
84
|
-
// Query by correlation
|
|
85
|
-
storyResultsTable.addGlobalSecondaryIndex({
|
|
86
|
-
indexName: 'CorrelationIndex',
|
|
87
|
-
partitionKey: { name: 'correlation', type: aws_cdk_lib_1.aws_dynamodb.AttributeType.STRING },
|
|
88
|
-
});
|
|
89
|
-
// Second table for the from logs ~ Second table because a GSI will dupe the data more then needed
|
|
90
|
-
// Also, we cant have a GSI on keys that can be undefined, this table will only contain
|
|
91
|
-
// logs with a fromCorrelation
|
|
92
|
-
const fromStoryResultsTable = new aws_cdk_lib_1.aws_dynamodb.Table(this, 'from-table', {
|
|
93
|
-
tableName: this.qpqResourceName(constants_1.QPQ_LOG_BUCKET_NAME, 'flog'),
|
|
94
|
-
partitionKey: { name: 'fromCorrelation', type: aws_cdk_lib_1.aws_dynamodb.AttributeType.STRING },
|
|
95
|
-
sortKey: { name: 'startedAtWithCorrelation', type: aws_cdk_lib_1.aws_dynamodb.AttributeType.STRING },
|
|
96
|
-
billingMode: aws_cdk_lib_1.aws_dynamodb.BillingMode.PAY_PER_REQUEST,
|
|
97
|
-
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
98
|
-
});
|
|
99
|
-
this.storyResultsTable = storyResultsTable;
|
|
100
|
-
this.fromStoryResultsTable = fromStoryResultsTable;
|
|
101
|
-
// Create a lambda that is trigged when files are written to the bucket
|
|
102
|
-
const func = new Function_1.Function(this, 'function', {
|
|
103
|
-
buildPath: path_1.default.join(__dirname, '../..'),
|
|
104
|
-
functionName: this.qpqResourceName(constants_1.QPQ_LOG_BUCKET_NAME, 'log'),
|
|
105
|
-
functionType: 'lambdas',
|
|
106
|
-
executorName: 'executeS3FileWriteEvent',
|
|
107
|
-
srcFilename: 'lambdaS3FileWriteEvent_log',
|
|
108
|
-
qpqConfig: props.qpqConfig,
|
|
109
|
-
awsAccountId: props.awsAccountId,
|
|
110
|
-
});
|
|
111
|
-
// Grant the Lambda function read access to the S3 bucket / dynamo table
|
|
112
|
-
// this.bucket.grantRead(func.lambdaFunction);
|
|
113
|
-
// storyResultsTable.grantWriteData(func.lambdaFunction);
|
|
114
|
-
this.bucket.addEventNotification(aws_cdk_lib_1.aws_s3.EventType.OBJECT_CREATED, new aws_cdk_lib_1.aws_s3_notifications.LambdaDestination(func.lambdaFunction));
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
exports.LogStorage = LogStorage;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { QPQConfig } from 'quidproquo-core';
|
|
2
|
-
import { Construct } from 'constructs';
|
|
3
|
-
import { aws_s3, aws_iam, aws_dynamodb } from 'aws-cdk-lib';
|
|
4
|
-
import { QpqConstructBlock, QpqConstructBlockProps } from '../base/QpqConstructBlock';
|
|
5
|
-
import { QpqResource } from '../base';
|
|
6
|
-
export interface LogStorageProps extends QpqConstructBlockProps {
|
|
7
|
-
}
|
|
8
|
-
export declare abstract class LogStorageConstructBase extends QpqConstructBlock implements QpqResource {
|
|
9
|
-
abstract bucket: aws_s3.IBucket;
|
|
10
|
-
abstract storyResultsTable: aws_dynamodb.ITable;
|
|
11
|
-
abstract fromStoryResultsTable: aws_dynamodb.ITable;
|
|
12
|
-
grantRead(grantee: aws_iam.IGrantable): void;
|
|
13
|
-
grantWrite(grantee: aws_iam.IGrantable): void;
|
|
14
|
-
grantAll(grantee: aws_iam.IGrantable): void;
|
|
15
|
-
}
|
|
16
|
-
export declare class LogStorage extends QpqConstructBlock {
|
|
17
|
-
readonly bucket: aws_s3.IBucket;
|
|
18
|
-
readonly storyResultsTable: aws_dynamodb.ITable;
|
|
19
|
-
readonly fromStoryResultsTable: aws_dynamodb.ITable;
|
|
20
|
-
static fromOtherStack(scope: Construct, id: string, qpqConfig: QPQConfig, awsAccountId: string, serviceBucketName: string): QpqResource;
|
|
21
|
-
constructor(scope: Construct, id: string, props: LogStorageProps);
|
|
22
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { aws_s3, aws_dynamodb, aws_s3_notifications } from 'aws-cdk-lib';
|
|
3
|
-
import * as cdk from 'aws-cdk-lib';
|
|
4
|
-
import { QpqConstructBlock } from '../base/QpqConstructBlock';
|
|
5
|
-
import { QPQ_LOG_BUCKET_NAME } from '../../constants';
|
|
6
|
-
import { Function } from './Function';
|
|
7
|
-
export class LogStorageConstructBase extends QpqConstructBlock {
|
|
8
|
-
grantRead(grantee) {
|
|
9
|
-
this.storyResultsTable.grantReadData(grantee);
|
|
10
|
-
this.fromStoryResultsTable.grantReadData(grantee);
|
|
11
|
-
this.bucket.grantRead(grantee);
|
|
12
|
-
}
|
|
13
|
-
grantWrite(grantee) {
|
|
14
|
-
this.storyResultsTable.grantWriteData(grantee);
|
|
15
|
-
this.fromStoryResultsTable.grantWriteData(grantee);
|
|
16
|
-
this.bucket.grantWrite(grantee);
|
|
17
|
-
}
|
|
18
|
-
grantAll(grantee) {
|
|
19
|
-
this.grantRead(grantee);
|
|
20
|
-
this.grantWrite(grantee);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
export class LogStorage extends QpqConstructBlock {
|
|
24
|
-
bucket;
|
|
25
|
-
storyResultsTable;
|
|
26
|
-
fromStoryResultsTable;
|
|
27
|
-
static fromOtherStack(scope, id, qpqConfig, awsAccountId, serviceBucketName) {
|
|
28
|
-
class Import extends LogStorageConstructBase {
|
|
29
|
-
bucket = aws_s3.Bucket.fromBucketName(scope, `${id}-log-storage`, this.qpqResourceName(serviceBucketName, 'log'));
|
|
30
|
-
storyResultsTable = aws_dynamodb.Table.fromTableName(scope, `${id}-log-table`, this.qpqResourceName(serviceBucketName, 'log'));
|
|
31
|
-
fromStoryResultsTable = aws_dynamodb.Table.fromTableName(scope, `${id}-flog-table`, this.qpqResourceName(serviceBucketName, 'flog'));
|
|
32
|
-
}
|
|
33
|
-
return new Import(scope, id, { qpqConfig, awsAccountId });
|
|
34
|
-
}
|
|
35
|
-
constructor(scope, id, props) {
|
|
36
|
-
super(scope, id, props);
|
|
37
|
-
this.bucket = new aws_s3.Bucket(this, 'bucket', {
|
|
38
|
-
bucketName: this.qpqResourceName(QPQ_LOG_BUCKET_NAME, 'log'),
|
|
39
|
-
// Disable public access to this bucket
|
|
40
|
-
publicReadAccess: false,
|
|
41
|
-
blockPublicAccess: aws_s3.BlockPublicAccess.BLOCK_ALL,
|
|
42
|
-
// Allow bucket to auto delete upon cdk:Destroy
|
|
43
|
-
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
44
|
-
autoDeleteObjects: true,
|
|
45
|
-
});
|
|
46
|
-
// Time based query over all logs for a given runtimeType
|
|
47
|
-
const storyResultsTable = new aws_dynamodb.Table(this, 'table', {
|
|
48
|
-
tableName: this.qpqResourceName(QPQ_LOG_BUCKET_NAME, 'log'),
|
|
49
|
-
partitionKey: { name: 'runtimeType', type: aws_dynamodb.AttributeType.STRING },
|
|
50
|
-
sortKey: { name: 'startedAtWithCorrelation', type: aws_dynamodb.AttributeType.STRING },
|
|
51
|
-
billingMode: aws_dynamodb.BillingMode.PAY_PER_REQUEST,
|
|
52
|
-
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
53
|
-
});
|
|
54
|
-
// Query by correlation
|
|
55
|
-
storyResultsTable.addGlobalSecondaryIndex({
|
|
56
|
-
indexName: 'CorrelationIndex',
|
|
57
|
-
partitionKey: { name: 'correlation', type: aws_dynamodb.AttributeType.STRING },
|
|
58
|
-
});
|
|
59
|
-
// Second table for the from logs ~ Second table because a GSI will dupe the data more then needed
|
|
60
|
-
// Also, we cant have a GSI on keys that can be undefined, this table will only contain
|
|
61
|
-
// logs with a fromCorrelation
|
|
62
|
-
const fromStoryResultsTable = new aws_dynamodb.Table(this, 'from-table', {
|
|
63
|
-
tableName: this.qpqResourceName(QPQ_LOG_BUCKET_NAME, 'flog'),
|
|
64
|
-
partitionKey: { name: 'fromCorrelation', type: aws_dynamodb.AttributeType.STRING },
|
|
65
|
-
sortKey: { name: 'startedAtWithCorrelation', type: aws_dynamodb.AttributeType.STRING },
|
|
66
|
-
billingMode: aws_dynamodb.BillingMode.PAY_PER_REQUEST,
|
|
67
|
-
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
68
|
-
});
|
|
69
|
-
this.storyResultsTable = storyResultsTable;
|
|
70
|
-
this.fromStoryResultsTable = fromStoryResultsTable;
|
|
71
|
-
// Create a lambda that is trigged when files are written to the bucket
|
|
72
|
-
const func = new Function(this, 'function', {
|
|
73
|
-
buildPath: path.join(__dirname, '../..'),
|
|
74
|
-
functionName: this.qpqResourceName(QPQ_LOG_BUCKET_NAME, 'log'),
|
|
75
|
-
functionType: 'lambdas',
|
|
76
|
-
executorName: 'executeS3FileWriteEvent',
|
|
77
|
-
srcFilename: 'lambdaS3FileWriteEvent_log',
|
|
78
|
-
qpqConfig: props.qpqConfig,
|
|
79
|
-
awsAccountId: props.awsAccountId,
|
|
80
|
-
});
|
|
81
|
-
// Grant the Lambda function read access to the S3 bucket / dynamo table
|
|
82
|
-
// this.bucket.grantRead(func.lambdaFunction);
|
|
83
|
-
// storyResultsTable.grantWriteData(func.lambdaFunction);
|
|
84
|
-
this.bucket.addEventNotification(aws_s3.EventType.OBJECT_CREATED, new aws_s3_notifications.LambdaDestination(func.lambdaFunction));
|
|
85
|
-
}
|
|
86
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
|
|
3
|
-
import { QPQConfig } from 'quidproquo-core';
|
|
4
|
-
import { Construct } from 'constructs';
|
|
5
|
-
import { aws_s3, aws_iam, aws_dynamodb, aws_s3_notifications } from 'aws-cdk-lib';
|
|
6
|
-
import * as cdk from 'aws-cdk-lib';
|
|
7
|
-
|
|
8
|
-
import { QpqConstructBlock, QpqConstructBlockProps } from '../base/QpqConstructBlock';
|
|
9
|
-
import { QpqResource } from '../base';
|
|
10
|
-
import { QPQ_LOG_BUCKET_NAME } from '../../constants';
|
|
11
|
-
import { Function } from './Function';
|
|
12
|
-
// import { qpqWebServerUtils } from '../../utils';
|
|
13
|
-
|
|
14
|
-
export interface LogStorageProps extends QpqConstructBlockProps {}
|
|
15
|
-
|
|
16
|
-
export abstract class LogStorageConstructBase extends QpqConstructBlock implements QpqResource {
|
|
17
|
-
abstract bucket: aws_s3.IBucket;
|
|
18
|
-
abstract storyResultsTable: aws_dynamodb.ITable;
|
|
19
|
-
abstract fromStoryResultsTable: aws_dynamodb.ITable;
|
|
20
|
-
|
|
21
|
-
public grantRead(grantee: aws_iam.IGrantable): void {
|
|
22
|
-
this.storyResultsTable.grantReadData(grantee);
|
|
23
|
-
this.fromStoryResultsTable.grantReadData(grantee);
|
|
24
|
-
this.bucket.grantRead(grantee);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public grantWrite(grantee: aws_iam.IGrantable): void {
|
|
28
|
-
this.storyResultsTable.grantWriteData(grantee);
|
|
29
|
-
this.fromStoryResultsTable.grantWriteData(grantee);
|
|
30
|
-
this.bucket.grantWrite(grantee);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
public grantAll(grantee: aws_iam.IGrantable): void {
|
|
34
|
-
this.grantRead(grantee);
|
|
35
|
-
this.grantWrite(grantee);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export class LogStorage extends QpqConstructBlock {
|
|
40
|
-
public readonly bucket: aws_s3.IBucket;
|
|
41
|
-
public readonly storyResultsTable: aws_dynamodb.ITable;
|
|
42
|
-
public readonly fromStoryResultsTable: aws_dynamodb.ITable;
|
|
43
|
-
|
|
44
|
-
static fromOtherStack(
|
|
45
|
-
scope: Construct,
|
|
46
|
-
id: string,
|
|
47
|
-
qpqConfig: QPQConfig,
|
|
48
|
-
awsAccountId: string,
|
|
49
|
-
serviceBucketName: string,
|
|
50
|
-
): QpqResource {
|
|
51
|
-
class Import extends LogStorageConstructBase {
|
|
52
|
-
bucket = aws_s3.Bucket.fromBucketName(
|
|
53
|
-
scope,
|
|
54
|
-
`${id}-log-storage`,
|
|
55
|
-
this.qpqResourceName(serviceBucketName, 'log'),
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
storyResultsTable = aws_dynamodb.Table.fromTableName(
|
|
59
|
-
scope,
|
|
60
|
-
`${id}-log-table`,
|
|
61
|
-
this.qpqResourceName(serviceBucketName, 'log'),
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
fromStoryResultsTable = aws_dynamodb.Table.fromTableName(
|
|
65
|
-
scope,
|
|
66
|
-
`${id}-flog-table`,
|
|
67
|
-
this.qpqResourceName(serviceBucketName, 'flog'),
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return new Import(scope, id, { qpqConfig, awsAccountId });
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
constructor(scope: Construct, id: string, props: LogStorageProps) {
|
|
75
|
-
super(scope, id, props);
|
|
76
|
-
|
|
77
|
-
this.bucket = new aws_s3.Bucket(this, 'bucket', {
|
|
78
|
-
bucketName: this.qpqResourceName(QPQ_LOG_BUCKET_NAME, 'log'),
|
|
79
|
-
|
|
80
|
-
// Disable public access to this bucket
|
|
81
|
-
publicReadAccess: false,
|
|
82
|
-
blockPublicAccess: aws_s3.BlockPublicAccess.BLOCK_ALL,
|
|
83
|
-
|
|
84
|
-
// Allow bucket to auto delete upon cdk:Destroy
|
|
85
|
-
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
86
|
-
autoDeleteObjects: true,
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
// Time based query over all logs for a given runtimeType
|
|
90
|
-
const storyResultsTable = new aws_dynamodb.Table(this, 'table', {
|
|
91
|
-
tableName: this.qpqResourceName(QPQ_LOG_BUCKET_NAME, 'log'),
|
|
92
|
-
partitionKey: { name: 'runtimeType', type: aws_dynamodb.AttributeType.STRING },
|
|
93
|
-
sortKey: { name: 'startedAtWithCorrelation', type: aws_dynamodb.AttributeType.STRING },
|
|
94
|
-
billingMode: aws_dynamodb.BillingMode.PAY_PER_REQUEST,
|
|
95
|
-
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
// Query by correlation
|
|
99
|
-
storyResultsTable.addGlobalSecondaryIndex({
|
|
100
|
-
indexName: 'CorrelationIndex',
|
|
101
|
-
partitionKey: { name: 'correlation', type: aws_dynamodb.AttributeType.STRING },
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
// Second table for the from logs ~ Second table because a GSI will dupe the data more then needed
|
|
105
|
-
// Also, we cant have a GSI on keys that can be undefined, this table will only contain
|
|
106
|
-
// logs with a fromCorrelation
|
|
107
|
-
const fromStoryResultsTable = new aws_dynamodb.Table(this, 'from-table', {
|
|
108
|
-
tableName: this.qpqResourceName(QPQ_LOG_BUCKET_NAME, 'flog'),
|
|
109
|
-
partitionKey: { name: 'fromCorrelation', type: aws_dynamodb.AttributeType.STRING },
|
|
110
|
-
sortKey: { name: 'startedAtWithCorrelation', type: aws_dynamodb.AttributeType.STRING },
|
|
111
|
-
billingMode: aws_dynamodb.BillingMode.PAY_PER_REQUEST,
|
|
112
|
-
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
this.storyResultsTable = storyResultsTable;
|
|
116
|
-
this.fromStoryResultsTable = fromStoryResultsTable;
|
|
117
|
-
|
|
118
|
-
// Create a lambda that is trigged when files are written to the bucket
|
|
119
|
-
const func = new Function(this, 'function', {
|
|
120
|
-
buildPath: path.join(__dirname, '../..'),
|
|
121
|
-
functionName: this.qpqResourceName(QPQ_LOG_BUCKET_NAME, 'log'),
|
|
122
|
-
functionType: 'lambdas',
|
|
123
|
-
executorName: 'executeS3FileWriteEvent',
|
|
124
|
-
srcFilename: 'lambdaS3FileWriteEvent_log',
|
|
125
|
-
|
|
126
|
-
qpqConfig: props.qpqConfig,
|
|
127
|
-
|
|
128
|
-
awsAccountId: props.awsAccountId,
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
// Grant the Lambda function read access to the S3 bucket / dynamo table
|
|
132
|
-
// this.bucket.grantRead(func.lambdaFunction);
|
|
133
|
-
// storyResultsTable.grantWriteData(func.lambdaFunction);
|
|
134
|
-
|
|
135
|
-
this.bucket.addEventNotification(
|
|
136
|
-
aws_s3.EventType.OBJECT_CREATED,
|
|
137
|
-
new aws_s3_notifications.LambdaDestination(func.lambdaFunction),
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
}
|