quidproquo-deploy-awscdk 0.0.89 → 0.0.91
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/constructs/basic/Function.d.ts +1 -0
- package/lib/constructs/basic/Function.js +1 -0
- package/lib/constructs/feature/core/index.d.ts +1 -0
- package/lib/constructs/feature/core/index.js +1 -0
- package/lib/constructs/feature/core/keyValueStore/QpqCoreKeyValueStoreConstruct.d.ts +18 -0
- package/lib/constructs/feature/core/keyValueStore/QpqCoreKeyValueStoreConstruct.js +41 -0
- package/lib/constructs/feature/core/keyValueStore/index.d.ts +1 -0
- package/lib/constructs/feature/core/keyValueStore/index.js +17 -0
- package/lib/constructs/feature/core/queue/QpqApiCoreQueueConstruct.js +2 -0
- package/lib/lambdas/lambdaAPIGatewayEvent.js +1 -2
- package/lib/stacks/InfQpqServiceStack.js +6 -0
- package/package.json +1 -1
- package/src/constructs/basic/Function.ts +4 -0
- package/src/constructs/feature/core/index.ts +1 -0
- package/src/constructs/feature/core/keyValueStore/QpqCoreKeyValueStoreConstruct.ts +61 -0
- package/src/constructs/feature/core/keyValueStore/index.ts +1 -0
- package/src/constructs/feature/core/queue/QpqApiCoreQueueConstruct.ts +3 -0
- package/src/lambdas/lambdaAPIGatewayEvent.ts +5 -3
- package/src/stacks/InfQpqServiceStack.ts +12 -0
|
@@ -12,6 +12,7 @@ export interface FunctionProps extends QpqConstructBlockProps {
|
|
|
12
12
|
[key: string]: string;
|
|
13
13
|
};
|
|
14
14
|
apiLayerVersions?: aws_lambda.ILayerVersion[];
|
|
15
|
+
reservedConcurrentExecutions?: number;
|
|
15
16
|
}
|
|
16
17
|
export declare class Function extends QpqConstructBlock {
|
|
17
18
|
readonly lambdaFunction: aws_lambda.Function;
|
|
@@ -43,6 +43,7 @@ class Function extends QpqConstructBlock_1.QpqConstructBlock {
|
|
|
43
43
|
code: aws_cdk_lib_1.aws_lambda.Code.fromAsset(path_1.default.join(props.buildPath, props.functionType)),
|
|
44
44
|
handler: `index.${props.executorName}`,
|
|
45
45
|
environment: props.environment,
|
|
46
|
+
reservedConcurrentExecutions: props.reservedConcurrentExecutions,
|
|
46
47
|
});
|
|
47
48
|
// Let lambdas read from the exported variables in cloudformation
|
|
48
49
|
this.lambdaFunction.addToRolePolicy(new aws_cdk_lib_1.aws_iam.PolicyStatement({
|
|
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./auth"), exports);
|
|
18
18
|
__exportStar(require("./eventBus"), exports);
|
|
19
|
+
__exportStar(require("./keyValueStore"), exports);
|
|
19
20
|
__exportStar(require("./parameter"), exports);
|
|
20
21
|
__exportStar(require("./queue"), exports);
|
|
21
22
|
__exportStar(require("./schedule"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { KeyValueStoreQPQConfigSetting, QPQConfig } from 'quidproquo-core';
|
|
2
|
+
import { QpqConstructBlock, QpqConstructBlockProps } from '../../../base/QpqConstructBlock';
|
|
3
|
+
import { Construct } from 'constructs';
|
|
4
|
+
import { aws_dynamodb, aws_iam } from 'aws-cdk-lib';
|
|
5
|
+
export interface QpqCoreKeyValueStoreConstructProps extends QpqConstructBlockProps {
|
|
6
|
+
keyValueStoreConfig: KeyValueStoreQPQConfigSetting;
|
|
7
|
+
}
|
|
8
|
+
export declare abstract class QpqCoreKeyValueStoreConstructBase extends QpqConstructBlock {
|
|
9
|
+
abstract table: aws_dynamodb.ITable;
|
|
10
|
+
grantRead(grantee: aws_iam.IGrantable): void;
|
|
11
|
+
grantWrite(grantee: aws_iam.IGrantable): void;
|
|
12
|
+
grantAll(grantee: aws_iam.IGrantable): void;
|
|
13
|
+
}
|
|
14
|
+
export declare class QpqCoreKeyValueStoreConstruct extends QpqCoreKeyValueStoreConstructBase {
|
|
15
|
+
table: aws_dynamodb.ITable;
|
|
16
|
+
static fromOtherStack(scope: Construct, id: string, qpqConfig: QPQConfig, awsAccountId: string, keyValueStoreName: string): QpqCoreKeyValueStoreConstructBase;
|
|
17
|
+
constructor(scope: Construct, id: string, props: QpqCoreKeyValueStoreConstructProps);
|
|
18
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QpqCoreKeyValueStoreConstruct = exports.QpqCoreKeyValueStoreConstructBase = void 0;
|
|
4
|
+
const QpqConstructBlock_1 = require("../../../base/QpqConstructBlock");
|
|
5
|
+
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
6
|
+
class QpqCoreKeyValueStoreConstructBase extends QpqConstructBlock_1.QpqConstructBlock {
|
|
7
|
+
grantRead(grantee) {
|
|
8
|
+
this.table.grantReadData(grantee);
|
|
9
|
+
}
|
|
10
|
+
grantWrite(grantee) {
|
|
11
|
+
this.table.grantWriteData(grantee);
|
|
12
|
+
}
|
|
13
|
+
grantAll(grantee) {
|
|
14
|
+
this.table.grantFullAccess(grantee);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.QpqCoreKeyValueStoreConstructBase = QpqCoreKeyValueStoreConstructBase;
|
|
18
|
+
class QpqCoreKeyValueStoreConstruct extends QpqCoreKeyValueStoreConstructBase {
|
|
19
|
+
static fromOtherStack(scope, id, qpqConfig, awsAccountId, keyValueStoreName) {
|
|
20
|
+
class Import extends QpqCoreKeyValueStoreConstructBase {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
this.table = aws_cdk_lib_1.aws_dynamodb.Table.fromTableName(this, 'table', this.qpqResourceName(keyValueStoreName, 'kvs'));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return new Import(scope, id, { qpqConfig, awsAccountId });
|
|
27
|
+
}
|
|
28
|
+
constructor(scope, id, props) {
|
|
29
|
+
super(scope, id, props);
|
|
30
|
+
this.table = new aws_cdk_lib_1.aws_dynamodb.Table(this, 'table', {
|
|
31
|
+
tableName: this.qpqResourceName(props.keyValueStoreConfig.keyValueStoreName, 'kvs'),
|
|
32
|
+
partitionKey: {
|
|
33
|
+
name: 'key',
|
|
34
|
+
type: aws_cdk_lib_1.aws_dynamodb.AttributeType.STRING,
|
|
35
|
+
},
|
|
36
|
+
billingMode: aws_cdk_lib_1.aws_dynamodb.BillingMode.PAY_PER_REQUEST,
|
|
37
|
+
timeToLiveAttribute: 'expires',
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.QpqCoreKeyValueStoreConstruct = QpqCoreKeyValueStoreConstruct;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './QpqCoreKeyValueStoreConstruct';
|
|
@@ -0,0 +1,17 @@
|
|
|
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("./QpqCoreKeyValueStoreConstruct"), exports);
|
|
@@ -46,6 +46,8 @@ class QpqApiCoreQueueConstruct extends QpqConstructBlock_1.QpqConstructBlock {
|
|
|
46
46
|
environment: {
|
|
47
47
|
queueQPQConfigSetting: JSON.stringify(props.queueConfig),
|
|
48
48
|
},
|
|
49
|
+
// TODO: Expose this as a config option
|
|
50
|
+
reservedConcurrentExecutions: 1,
|
|
49
51
|
});
|
|
50
52
|
// TODO: Make this a utility function
|
|
51
53
|
const grantables = qpqDeployAwsCdkUtils.getQqpGrantableResources(this, 'grantable', this.qpqConfig, props.awsAccountId);
|
|
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.executeAPIGatewayEvent = exports.getAPIGatewayEventExecutor = void 0;
|
|
16
16
|
const quidproquo_actionprocessor_node_1 = require("quidproquo-actionprocessor-node");
|
|
17
17
|
const quidproquo_actionprocessor_awslambda_1 = require("quidproquo-actionprocessor-awslambda");
|
|
18
|
-
const quidproquo_actionprocessor_node_2 = require("quidproquo-actionprocessor-node");
|
|
19
18
|
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
20
19
|
const quidproquo_core_1 = require("quidproquo-core");
|
|
21
20
|
const lambdaConfig_1 = require("./lambdaConfig");
|
|
@@ -45,7 +44,7 @@ const getAPIGatewayEventExecutor = (dynamicModuleLoader, getCustomActionProcesso
|
|
|
45
44
|
const cdkConfig = yield (0, lambdaConfig_1.getLambdaConfigs)();
|
|
46
45
|
// Build a processor for the session and stuff
|
|
47
46
|
// Remove the non route ones ~ let the story execute action add them
|
|
48
|
-
const storyActionProcessor = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, quidproquo_actionprocessor_node_1.coreActionProcessor), quidproquo_actionprocessor_node_1.webserverActionProcessor), (0, quidproquo_actionprocessor_awslambda_1.getAPIGatewayEventActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetSecretActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParameterActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParametersActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getSystemActionProcessor)(dynamicModuleLoader)), (0, quidproquo_actionprocessor_awslambda_1.getFileActionProcessor)(cdkConfig.qpqConfig)), (0,
|
|
47
|
+
const storyActionProcessor = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, quidproquo_actionprocessor_node_1.coreActionProcessor), quidproquo_actionprocessor_node_1.webserverActionProcessor), (0, quidproquo_actionprocessor_awslambda_1.getAPIGatewayEventActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetSecretActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParameterActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getConfigGetParametersActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getSystemActionProcessor)(dynamicModuleLoader)), (0, quidproquo_actionprocessor_awslambda_1.getFileActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_node_1.getConfigActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getQueueActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getEventBusActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getUserDirectoryActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getWebEntryActionProcessor)(cdkConfig.qpqConfig)), (0, quidproquo_actionprocessor_awslambda_1.getServiceFunctionActionProcessor)(cdkConfig.qpqConfig)), getCustomActionProcessors(cdkConfig.qpqConfig)), (0, qpq_custom_action_processors_loader_1.default)());
|
|
49
48
|
const logger = (result) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
49
|
// addResult(
|
|
51
50
|
// envConfig.appName,
|
|
@@ -56,6 +56,12 @@ class InfQpqServiceStack extends QpqServiceStack_1.QpqServiceStack {
|
|
|
56
56
|
qpqConfig: props.qpqConfig,
|
|
57
57
|
eventBusConfig: setting,
|
|
58
58
|
}));
|
|
59
|
+
// key value store
|
|
60
|
+
const keyValueStores = quidproquo_core_1.qpqCoreUtils.getAllKeyValueStores(props.qpqConfig).map((setting) => new constructs_1.QpqCoreKeyValueStoreConstruct(this, quidproquo_core_1.qpqCoreUtils.getUniqueKeyForSetting(setting), {
|
|
61
|
+
awsAccountId: props.awsAccountId,
|
|
62
|
+
qpqConfig: props.qpqConfig,
|
|
63
|
+
keyValueStoreConfig: setting,
|
|
64
|
+
}));
|
|
59
65
|
}
|
|
60
66
|
}
|
|
61
67
|
exports.InfQpqServiceStack = InfQpqServiceStack;
|
package/package.json
CHANGED
|
@@ -20,6 +20,8 @@ export interface FunctionProps extends QpqConstructBlockProps {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
apiLayerVersions?: aws_lambda.ILayerVersion[];
|
|
23
|
+
|
|
24
|
+
reservedConcurrentExecutions?: number;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
export class Function extends QpqConstructBlock {
|
|
@@ -40,6 +42,8 @@ export class Function extends QpqConstructBlock {
|
|
|
40
42
|
handler: `index.${props.executorName}`,
|
|
41
43
|
|
|
42
44
|
environment: props.environment,
|
|
45
|
+
|
|
46
|
+
reservedConcurrentExecutions: props.reservedConcurrentExecutions,
|
|
43
47
|
});
|
|
44
48
|
|
|
45
49
|
// Let lambdas read from the exported variables in cloudformation
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { KeyValueStoreQPQConfigSetting, QPQConfig } from 'quidproquo-core';
|
|
2
|
+
import { QpqConstructBlock, QpqConstructBlockProps } from '../../../base/QpqConstructBlock';
|
|
3
|
+
|
|
4
|
+
import { Construct } from 'constructs';
|
|
5
|
+
import { aws_dynamodb, aws_iam } from 'aws-cdk-lib';
|
|
6
|
+
|
|
7
|
+
export interface QpqCoreKeyValueStoreConstructProps extends QpqConstructBlockProps {
|
|
8
|
+
keyValueStoreConfig: KeyValueStoreQPQConfigSetting;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export abstract class QpqCoreKeyValueStoreConstructBase extends QpqConstructBlock {
|
|
12
|
+
abstract table: aws_dynamodb.ITable;
|
|
13
|
+
|
|
14
|
+
public grantRead(grantee: aws_iam.IGrantable) {
|
|
15
|
+
this.table.grantReadData(grantee);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public grantWrite(grantee: aws_iam.IGrantable) {
|
|
19
|
+
this.table.grantWriteData(grantee);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public grantAll(grantee: aws_iam.IGrantable) {
|
|
23
|
+
this.table.grantFullAccess(grantee);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class QpqCoreKeyValueStoreConstruct extends QpqCoreKeyValueStoreConstructBase {
|
|
28
|
+
table: aws_dynamodb.ITable;
|
|
29
|
+
|
|
30
|
+
static fromOtherStack(
|
|
31
|
+
scope: Construct,
|
|
32
|
+
id: string,
|
|
33
|
+
qpqConfig: QPQConfig,
|
|
34
|
+
awsAccountId: string,
|
|
35
|
+
keyValueStoreName: string,
|
|
36
|
+
): QpqCoreKeyValueStoreConstructBase {
|
|
37
|
+
class Import extends QpqCoreKeyValueStoreConstructBase {
|
|
38
|
+
table = aws_dynamodb.Table.fromTableName(
|
|
39
|
+
this,
|
|
40
|
+
'table',
|
|
41
|
+
this.qpqResourceName(keyValueStoreName, 'kvs'),
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return new Import(scope, id, { qpqConfig, awsAccountId });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
constructor(scope: Construct, id: string, props: QpqCoreKeyValueStoreConstructProps) {
|
|
49
|
+
super(scope, id, props);
|
|
50
|
+
|
|
51
|
+
this.table = new aws_dynamodb.Table(this, 'table', {
|
|
52
|
+
tableName: this.qpqResourceName(props.keyValueStoreConfig.keyValueStoreName, 'kvs'),
|
|
53
|
+
partitionKey: {
|
|
54
|
+
name: 'key',
|
|
55
|
+
type: aws_dynamodb.AttributeType.STRING,
|
|
56
|
+
},
|
|
57
|
+
billingMode: aws_dynamodb.BillingMode.PAY_PER_REQUEST,
|
|
58
|
+
timeToLiveAttribute: 'expires',
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './QpqCoreKeyValueStoreConstruct';
|
|
@@ -36,6 +36,9 @@ export class QpqApiCoreQueueConstruct extends QpqConstructBlock {
|
|
|
36
36
|
environment: {
|
|
37
37
|
queueQPQConfigSetting: JSON.stringify(props.queueConfig),
|
|
38
38
|
},
|
|
39
|
+
|
|
40
|
+
// TODO: Expose this as a config option
|
|
41
|
+
reservedConcurrentExecutions: 1,
|
|
39
42
|
});
|
|
40
43
|
|
|
41
44
|
// TODO: Make this a utility function
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
coreActionProcessor,
|
|
3
|
+
webserverActionProcessor,
|
|
4
|
+
getConfigActionProcessor,
|
|
5
|
+
} from 'quidproquo-actionprocessor-node';
|
|
2
6
|
|
|
3
7
|
import {
|
|
4
8
|
getAPIGatewayEventActionProcessor,
|
|
@@ -16,8 +20,6 @@ import {
|
|
|
16
20
|
DynamicModuleLoader,
|
|
17
21
|
} from 'quidproquo-actionprocessor-awslambda';
|
|
18
22
|
|
|
19
|
-
import { getConfigActionProcessor } from 'quidproquo-actionprocessor-node';
|
|
20
|
-
|
|
21
23
|
import { qpqWebServerUtils } from 'quidproquo-webserver';
|
|
22
24
|
|
|
23
25
|
import { createRuntime, askProcessEvent, ErrorTypeEnum } from 'quidproquo-core';
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
QpqWebserverDomainConstruct,
|
|
14
14
|
QpqCoreUserDirectoryConstruct,
|
|
15
15
|
QpqWebserverApiKeyConstruct,
|
|
16
|
+
QpqCoreKeyValueStoreConstruct,
|
|
16
17
|
} from '../constructs';
|
|
17
18
|
|
|
18
19
|
export interface InfQpqServiceStackProps extends QpqServiceStackProps {}
|
|
@@ -108,5 +109,16 @@ export class InfQpqServiceStack extends QpqServiceStack {
|
|
|
108
109
|
eventBusConfig: setting,
|
|
109
110
|
}),
|
|
110
111
|
);
|
|
112
|
+
|
|
113
|
+
// key value store
|
|
114
|
+
const keyValueStores = qpqCoreUtils.getAllKeyValueStores(props.qpqConfig).map(
|
|
115
|
+
(setting) =>
|
|
116
|
+
new QpqCoreKeyValueStoreConstruct(this, qpqCoreUtils.getUniqueKeyForSetting(setting), {
|
|
117
|
+
awsAccountId: props.awsAccountId,
|
|
118
|
+
qpqConfig: props.qpqConfig,
|
|
119
|
+
|
|
120
|
+
keyValueStoreConfig: setting,
|
|
121
|
+
}),
|
|
122
|
+
);
|
|
111
123
|
}
|
|
112
124
|
}
|