quidproquo-deploy-awscdk 0.0.75 → 0.0.76
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.js +5 -0
- package/lib/constructs/feature/webserver/api/QpqWebserverApiConstruct.js +6 -6
- package/lib/constructs/feature/webserver/apiKey/QpqWebserverApiKeyConstruct.d.ts +11 -0
- package/lib/constructs/feature/webserver/apiKey/QpqWebserverApiKeyConstruct.js +44 -0
- package/lib/constructs/feature/webserver/apiKey/index.d.ts +1 -0
- package/lib/constructs/feature/webserver/apiKey/index.js +17 -0
- package/lib/constructs/feature/webserver/index.d.ts +1 -0
- package/lib/constructs/feature/webserver/index.js +1 -0
- package/lib/stacks/InfQpqServiceStack.js +6 -0
- package/package.json +1 -1
- package/src/constructs/basic/Function.ts +8 -0
- package/src/constructs/feature/webserver/api/QpqWebserverApiConstruct.ts +7 -6
- package/src/constructs/feature/webserver/apiKey/QpqWebserverApiKeyConstruct.ts +35 -0
- package/src/constructs/feature/webserver/apiKey/index.ts +1 -0
- package/src/constructs/feature/webserver/index.ts +1 -0
- package/src/stacks/InfQpqServiceStack.ts +12 -0
|
@@ -49,6 +49,11 @@ class Function extends QpqConstructBlock_1.QpqConstructBlock {
|
|
|
49
49
|
actions: ['cloudformation:ListExports'],
|
|
50
50
|
resources: ['*'],
|
|
51
51
|
}));
|
|
52
|
+
// Let lambdas read from api keys in api gateway
|
|
53
|
+
this.lambdaFunction.addToRolePolicy(new aws_cdk_lib_1.aws_iam.PolicyStatement({
|
|
54
|
+
actions: ['apigateway:GET'],
|
|
55
|
+
resources: ['*'],
|
|
56
|
+
}));
|
|
52
57
|
}
|
|
53
58
|
}
|
|
54
59
|
exports.Function = Function;
|
|
@@ -86,12 +86,12 @@ class QpqWebserverApiConstruct extends QpqConstructBlock_1.QpqConstructBlock {
|
|
|
86
86
|
// });
|
|
87
87
|
// apiKeys.forEach((apiKey) => {
|
|
88
88
|
// const name = `${props.apiConfig.apiName}-${apiKey.name}`;
|
|
89
|
-
//
|
|
90
|
-
//
|
|
91
|
-
//
|
|
92
|
-
//
|
|
93
|
-
//
|
|
94
|
-
// );
|
|
89
|
+
// const newApiKey = api.addApiKey(this.qpqResourceName(name, 'apiKey'), {
|
|
90
|
+
// description: apiKey.description,
|
|
91
|
+
// apiKeyName: this.resourceName(name),
|
|
92
|
+
// value: apiKey.value,
|
|
93
|
+
// });
|
|
94
|
+
// // usagePlan.addApiKey(newApiKey);
|
|
95
95
|
// });
|
|
96
96
|
// Map all requests to this service to /serviceName/*
|
|
97
97
|
new aws_cdk_lib_1.aws_apigateway.BasePathMapping(this, 'rest-bpm', {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { aws_lambda } from 'aws-cdk-lib';
|
|
2
|
+
import { Construct } from 'constructs';
|
|
3
|
+
import { ApiKeyQPQWebServerConfigSetting } from 'quidproquo-webserver';
|
|
4
|
+
import { QpqConstructBlock, QpqConstructBlockProps } from '../../../base/QpqConstructBlock';
|
|
5
|
+
export interface QpqWebserverApiKeyConstructProps extends QpqConstructBlockProps {
|
|
6
|
+
apiKeyConfig: ApiKeyQPQWebServerConfigSetting;
|
|
7
|
+
apiLayerVersions?: aws_lambda.ILayerVersion[];
|
|
8
|
+
}
|
|
9
|
+
export declare class QpqWebserverApiKeyConstruct extends QpqConstructBlock {
|
|
10
|
+
constructor(scope: Construct, id: string, props: QpqWebserverApiKeyConstructProps);
|
|
11
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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.QpqWebserverApiKeyConstruct = void 0;
|
|
27
|
+
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
28
|
+
const QpqConstructBlock_1 = require("../../../base/QpqConstructBlock");
|
|
29
|
+
const qpqDeployAwsCdkUtils = __importStar(require("../../../../utils"));
|
|
30
|
+
const quidproquo_actionprocessor_awslambda_1 = require("quidproquo-actionprocessor-awslambda");
|
|
31
|
+
class QpqWebserverApiKeyConstruct extends QpqConstructBlock_1.QpqConstructBlock {
|
|
32
|
+
constructor(scope, id, props) {
|
|
33
|
+
super(scope, id, props);
|
|
34
|
+
const apiKeyConfig = props.apiKeyConfig.apiKey;
|
|
35
|
+
const apiKey = new aws_cdk_lib_1.aws_apigateway.ApiKey(this, apiKeyConfig.name, {
|
|
36
|
+
description: apiKeyConfig.description,
|
|
37
|
+
apiKeyName: this.resourceName(apiKeyConfig.name),
|
|
38
|
+
value: apiKeyConfig.value,
|
|
39
|
+
enabled: true,
|
|
40
|
+
});
|
|
41
|
+
qpqDeployAwsCdkUtils.exportStackValue(this, quidproquo_actionprocessor_awslambda_1.awsNamingUtils.getCFExportNameApiKeyIdFromConfig(apiKeyConfig.name, props.qpqConfig), apiKey.keyId);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.QpqWebserverApiKeyConstruct = QpqWebserverApiKeyConstruct;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './QpqWebserverApiKeyConstruct';
|
|
@@ -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("./QpqWebserverApiKeyConstruct"), exports);
|
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./api"), exports);
|
|
18
|
+
__exportStar(require("./apiKey"), exports);
|
|
18
19
|
__exportStar(require("./domain"), exports);
|
|
19
20
|
__exportStar(require("./redirect"), exports);
|
|
20
21
|
__exportStar(require("./webEntry"), exports);
|
|
@@ -44,6 +44,12 @@ class InfQpqServiceStack extends QpqServiceStack_1.QpqServiceStack {
|
|
|
44
44
|
qpqConfig: props.qpqConfig,
|
|
45
45
|
userDirectoryConfig: setting,
|
|
46
46
|
}));
|
|
47
|
+
// Api Keys
|
|
48
|
+
const apiKeys = quidproquo_webserver_1.qpqWebServerUtils.getAllApiKeyConfigs(props.qpqConfig).map((setting) => new constructs_1.QpqWebserverApiKeyConstruct(this, quidproquo_core_1.qpqCoreUtils.getUniqueKeyForSetting(setting), {
|
|
49
|
+
awsAccountId: props.awsAccountId,
|
|
50
|
+
qpqConfig: props.qpqConfig,
|
|
51
|
+
apiKeyConfig: setting,
|
|
52
|
+
}));
|
|
47
53
|
}
|
|
48
54
|
}
|
|
49
55
|
exports.InfQpqServiceStack = InfQpqServiceStack;
|
package/package.json
CHANGED
|
@@ -49,5 +49,13 @@ export class Function extends QpqConstructBlock {
|
|
|
49
49
|
resources: ['*'],
|
|
50
50
|
}),
|
|
51
51
|
);
|
|
52
|
+
|
|
53
|
+
// Let lambdas read from api keys in api gateway
|
|
54
|
+
this.lambdaFunction.addToRolePolicy(
|
|
55
|
+
new aws_iam.PolicyStatement({
|
|
56
|
+
actions: ['apigateway:GET'],
|
|
57
|
+
resources: ['*'],
|
|
58
|
+
}),
|
|
59
|
+
);
|
|
52
60
|
}
|
|
53
61
|
}
|
|
@@ -90,12 +90,13 @@ export class QpqWebserverApiConstruct extends QpqConstructBlock {
|
|
|
90
90
|
|
|
91
91
|
// apiKeys.forEach((apiKey) => {
|
|
92
92
|
// const name = `${props.apiConfig.apiName}-${apiKey.name}`;
|
|
93
|
-
//
|
|
94
|
-
//
|
|
95
|
-
//
|
|
96
|
-
//
|
|
97
|
-
//
|
|
98
|
-
|
|
93
|
+
// const newApiKey = api.addApiKey(this.qpqResourceName(name, 'apiKey'), {
|
|
94
|
+
// description: apiKey.description,
|
|
95
|
+
// apiKeyName: this.resourceName(name),
|
|
96
|
+
// value: apiKey.value,
|
|
97
|
+
// });
|
|
98
|
+
|
|
99
|
+
// // usagePlan.addApiKey(newApiKey);
|
|
99
100
|
// });
|
|
100
101
|
|
|
101
102
|
// Map all requests to this service to /serviceName/*
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { aws_apigateway, aws_lambda } from 'aws-cdk-lib';
|
|
2
|
+
import { Construct } from 'constructs';
|
|
3
|
+
|
|
4
|
+
import { ApiKeyQPQWebServerConfigSetting, qpqWebServerUtils } from 'quidproquo-webserver';
|
|
5
|
+
|
|
6
|
+
import { QpqConstructBlock, QpqConstructBlockProps } from '../../../base/QpqConstructBlock';
|
|
7
|
+
|
|
8
|
+
import * as qpqDeployAwsCdkUtils from '../../../../utils';
|
|
9
|
+
import { awsNamingUtils } from 'quidproquo-actionprocessor-awslambda';
|
|
10
|
+
|
|
11
|
+
export interface QpqWebserverApiKeyConstructProps extends QpqConstructBlockProps {
|
|
12
|
+
apiKeyConfig: ApiKeyQPQWebServerConfigSetting;
|
|
13
|
+
apiLayerVersions?: aws_lambda.ILayerVersion[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class QpqWebserverApiKeyConstruct extends QpqConstructBlock {
|
|
17
|
+
constructor(scope: Construct, id: string, props: QpqWebserverApiKeyConstructProps) {
|
|
18
|
+
super(scope, id, props);
|
|
19
|
+
|
|
20
|
+
const apiKeyConfig = props.apiKeyConfig.apiKey;
|
|
21
|
+
|
|
22
|
+
const apiKey = new aws_apigateway.ApiKey(this, apiKeyConfig.name, {
|
|
23
|
+
description: apiKeyConfig.description,
|
|
24
|
+
apiKeyName: this.resourceName(apiKeyConfig.name),
|
|
25
|
+
value: apiKeyConfig.value,
|
|
26
|
+
enabled: true,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
qpqDeployAwsCdkUtils.exportStackValue(
|
|
30
|
+
this,
|
|
31
|
+
awsNamingUtils.getCFExportNameApiKeyIdFromConfig(apiKeyConfig.name, props.qpqConfig),
|
|
32
|
+
apiKey.keyId,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './QpqWebserverApiKeyConstruct';
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
QpqCoreSecretConstruct,
|
|
12
12
|
QpqWebserverDomainConstruct,
|
|
13
13
|
QpqCoreUserDirectoryConstruct,
|
|
14
|
+
QpqWebserverApiKeyConstruct,
|
|
14
15
|
} from '../constructs';
|
|
15
16
|
|
|
16
17
|
export interface InfQpqServiceStackProps extends QpqServiceStackProps {}
|
|
@@ -84,5 +85,16 @@ export class InfQpqServiceStack extends QpqServiceStack {
|
|
|
84
85
|
userDirectoryConfig: setting,
|
|
85
86
|
}),
|
|
86
87
|
);
|
|
88
|
+
|
|
89
|
+
// Api Keys
|
|
90
|
+
const apiKeys = qpqWebServerUtils.getAllApiKeyConfigs(props.qpqConfig).map(
|
|
91
|
+
(setting) =>
|
|
92
|
+
new QpqWebserverApiKeyConstruct(this, qpqCoreUtils.getUniqueKeyForSetting(setting), {
|
|
93
|
+
awsAccountId: props.awsAccountId,
|
|
94
|
+
qpqConfig: props.qpqConfig,
|
|
95
|
+
|
|
96
|
+
apiKeyConfig: setting,
|
|
97
|
+
}),
|
|
98
|
+
);
|
|
87
99
|
}
|
|
88
100
|
}
|