@byaga/cdk-patterns 0.9.3 → 0.11.0
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/.fleet/run.json +11 -0
- package/LICENSE.md +21 -0
- package/README.md +43 -0
- package/archive/ApiAttachPoint.ts +9 -0
- package/archive/ApiCertificate.ts +32 -0
- package/{lib/CognitoApiGatewayAuthorizer.d.ts → archive/CognitoApiGatewayAuthorizer.ts} +13 -7
- package/archive/DynamoDbTable.ts +40 -0
- package/archive/ICorsConfig.ts +5 -0
- package/archive/IDomainConfig.ts +8 -0
- package/archive/IHostedZoneConfig.ts +5 -0
- package/archive/NodeJsLambdaLayer.ts +42 -0
- package/archive/Output.ts +11 -0
- package/{lib/RestApi.js → archive/RestApi.ts} +96 -60
- package/{lib/Role.d.ts → archive/Role.ts} +165 -139
- package/archive/StaticWebSite.ts +159 -0
- package/archive/index.ts +18 -0
- package/archive/methods/apply-schema-to-method-options.ts +38 -0
- package/archive/methods/attach-function-to-api.ts +69 -0
- package/lib/build/copy-files.d.ts +8 -0
- package/lib/{methods/empty-directory.js → build/copy-files.js} +22 -15
- package/lib/build/generate-hash.d.ts +7 -0
- package/lib/build/generate-hash.js +31 -0
- package/lib/build/get-files.d.ts +9 -0
- package/lib/build/get-files.js +38 -0
- package/lib/build/get-source-directory.d.ts +18 -0
- package/lib/build/get-source-directory.js +38 -0
- package/lib/build/hash-file.d.ts +18 -0
- package/lib/build/hash-file.js +45 -0
- package/lib/build/nodejs/build-ecmascript.d.ts +9 -0
- package/lib/build/nodejs/build-ecmascript.js +20 -0
- package/lib/build/nodejs/build-node-source.d.ts +12 -0
- package/lib/build/nodejs/build-node-source.js +39 -0
- package/lib/build/nodejs/build-typescript.d.ts +8 -0
- package/lib/build/nodejs/build-typescript.js +33 -0
- package/lib/build/nodejs/install-node-modules.d.ts +12 -0
- package/lib/build/nodejs/install-node-modules.js +30 -0
- package/lib/create-stack.d.ts +38 -0
- package/lib/create-stack.js +46 -0
- package/lib/generate-identifier.d.ts +27 -0
- package/lib/generate-identifier.js +65 -0
- package/lib/index.d.ts +7 -15
- package/lib/index.js +40 -25
- package/lib/lambda/create-function.d.ts +20 -0
- package/lib/lambda/create-function.js +39 -0
- package/lib/lambda/create-nodejs-lambda.d.ts +28 -0
- package/lib/lambda/create-nodejs-lambda.js +38 -0
- package/lib/lambda-layer/apply-honeycomb-to-lambda.d.ts +2 -0
- package/lib/lambda-layer/apply-honeycomb-to-lambda.js +25 -0
- package/lib/lambda-layer/get-layer.d.ts +2 -0
- package/lib/lambda-layer/get-layer.js +20 -0
- package/lib/lambda-layer/layer-cache.d.ts +3 -0
- package/lib/lambda-layer/layer-cache.js +12 -0
- package/lib/ssm/SsmParameter.d.ts +12 -0
- package/lib/ssm/get-existing-parameter.d.ts +9 -0
- package/lib/ssm/get-existing-parameter.js +41 -0
- package/lib/ssm/grant-read.d.ts +7 -0
- package/lib/ssm/grant-read.js +24 -0
- package/lib/ssm/index.d.ts +3 -0
- package/lib/ssm/index.js +9 -0
- package/lib/ssm/parameter-cache.d.ts +13 -0
- package/lib/ssm/parameter-cache.js +23 -0
- package/lib/ssm/string-value.d.ts +8 -0
- package/lib/ssm/string-value.js +14 -0
- package/lib/tools/duration.d.ts +10 -0
- package/lib/tools/duration.js +28 -0
- package/package.json +25 -11
- package/jest.config.js +0 -16
- package/lib/ApiCertificate.d.ts +0 -10
- package/lib/ApiCertificate.js +0 -31
- package/lib/CognitoApiGatewayAuthorizer.js +0 -24
- package/lib/DeployStack.d.ts +0 -23
- package/lib/DeployStack.js +0 -58
- package/lib/DynamoDbTable.d.ts +0 -12
- package/lib/DynamoDbTable.js +0 -34
- package/lib/FunctionIntegration.d.ts +0 -25
- package/lib/FunctionIntegration.js +0 -65
- package/lib/ICorsConfig.d.ts +0 -5
- package/lib/IDeployStack.d.ts +0 -20
- package/lib/IDeployStack.js +0 -48
- package/lib/IDomainConfig.d.ts +0 -7
- package/lib/IDomainConfig.js +0 -2
- package/lib/IHostedZoneConfig.d.ts +0 -5
- package/lib/IHostedZoneConfig.js +0 -2
- package/lib/IStackArguments.d.ts +0 -8
- package/lib/IStackArguments.js +0 -2
- package/lib/NodeJsLambda.d.ts +0 -13
- package/lib/NodeJsLambda.js +0 -28
- package/lib/NodeJsLambdaLayer.d.ts +0 -12
- package/lib/NodeJsLambdaLayer.js +0 -24
- package/lib/Output.d.ts +0 -5
- package/lib/Output.js +0 -13
- package/lib/RestApi.d.ts +0 -28
- package/lib/Role.js +0 -27
- package/lib/SsmParameter.d.ts +0 -18
- package/lib/SsmParameter.js +0 -40
- package/lib/StaticWebSite.d.ts +0 -17
- package/lib/StaticWebSite.js +0 -122
- package/lib/methods/apply-honeycomb-to-lambda.d.ts +0 -3
- package/lib/methods/apply-honeycomb-to-lambda.js +0 -23
- package/lib/methods/apply-honeycomb-to-lambda.spec.d.ts +0 -1
- package/lib/methods/apply-honeycomb-to-lambda.spec.js +0 -61
- package/lib/methods/build-node-source.d.ts +0 -13
- package/lib/methods/build-node-source.js +0 -105
- package/lib/methods/duration.d.ts +0 -8
- package/lib/methods/duration.js +0 -22
- package/lib/methods/empty-directory.d.ts +0 -2
- package/lib/methods/generate-hash.d.ts +0 -15
- package/lib/methods/generate-hash.js +0 -59
- package/lib/methods/get-source-directory.d.ts +0 -4
- package/lib/methods/get-source-directory.js +0 -37
- package/lib/methods/walk-directory.d.ts +0 -14
- package/lib/methods/walk-directory.js +0 -48
- package/test-results/html/index.html +0 -1
- package/test-results/html/jest-html-reporters-attach/index/index.js +0 -3
- package/test-results/html/jest-html-reporters-attach/index/result.js +0 -1
- package/test-results/junit/junit.xml +0 -13
- /package/lib/{ICorsConfig.js → ssm/SsmParameter.js} +0 -0
package/lib/DeployStack.d.ts
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
import { Stack } from 'aws-cdk-lib';
|
2
|
-
import IStackArguments from './IStackArguments';
|
3
|
-
import { IConstruct } from "constructs";
|
4
|
-
export declare class DeployStack extends Stack {
|
5
|
-
registry: {
|
6
|
-
[t: string]: {
|
7
|
-
[n: string]: any;
|
8
|
-
};
|
9
|
-
};
|
10
|
-
stage: string;
|
11
|
-
name: string;
|
12
|
-
project: string;
|
13
|
-
genName(...name: string[]): string;
|
14
|
-
genStackName(stackName: string, ...name: string[]): string;
|
15
|
-
genId(...name: string[]): string;
|
16
|
-
genStackId(stackName: string, ...name: string[]): string;
|
17
|
-
static genStackResourceName(stackName: string, resource: string, stage?: string): string;
|
18
|
-
static genStackResourceId(stackName: string, resource: string, stage?: string): string;
|
19
|
-
constructor(scope: IConstruct, props: IStackArguments);
|
20
|
-
get(type: string, name: string): any;
|
21
|
-
set(type: string, name: string, instance: any): any;
|
22
|
-
}
|
23
|
-
export default DeployStack;
|
package/lib/DeployStack.js
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.DeployStack = void 0;
|
4
|
-
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
5
|
-
class DeployStack extends aws_cdk_lib_1.Stack {
|
6
|
-
registry = {};
|
7
|
-
stage;
|
8
|
-
name;
|
9
|
-
project;
|
10
|
-
genName(...name) {
|
11
|
-
return DeployStack.genStackResourceName(this.name, name.filter(n => !!n).join('-'), this.stage);
|
12
|
-
}
|
13
|
-
genStackName(stackName, ...name) {
|
14
|
-
return DeployStack.genStackResourceName(stackName, name.filter(n => !!n).join('-'), this.stage);
|
15
|
-
}
|
16
|
-
genId(...name) {
|
17
|
-
return DeployStack.genStackResourceId(this.name, name.filter(n => !!n).join('-'), this.stage);
|
18
|
-
}
|
19
|
-
genStackId(stackName, ...name) {
|
20
|
-
return DeployStack.genStackResourceId(stackName, name.filter(n => !!n).join('-'), this.stage);
|
21
|
-
}
|
22
|
-
static genStackResourceName(stackName, resource, stage = 'develop') {
|
23
|
-
let name = stackName[0].toLowerCase() + stackName.substring(1);
|
24
|
-
name = name.replace(/[A-Z]/g, v => '-' + v.toLowerCase());
|
25
|
-
return `${name}-${stage}-${resource}`.toLowerCase();
|
26
|
-
}
|
27
|
-
static genStackResourceId(stackName, resource, stage = 'develop') {
|
28
|
-
const constructName = `${stackName}-${stage}-${resource}`;
|
29
|
-
return constructName[0].toUpperCase() + constructName.substring(1).replace(/-./g, v => (v[1] || '').toUpperCase());
|
30
|
-
}
|
31
|
-
constructor(scope, props) {
|
32
|
-
const options = (props || {});
|
33
|
-
const { stage = 'develop' } = options;
|
34
|
-
super(scope, props.stackName + '-' + stage, {
|
35
|
-
...props,
|
36
|
-
stackName: props.stackName + '-' + stage
|
37
|
-
});
|
38
|
-
const stack = this;
|
39
|
-
stack.name = props.stackName || '';
|
40
|
-
stack.stage = stage;
|
41
|
-
stack.project = props.project;
|
42
|
-
stack.tags.setTag('stage', stage);
|
43
|
-
stack.tags.setTag('stack', this.genName('ui-stack'));
|
44
|
-
stack.tags.setTag('project', props.project);
|
45
|
-
stack.tags.setTag('owner', props.owner);
|
46
|
-
}
|
47
|
-
get(type, name) {
|
48
|
-
const items = this.registry[type];
|
49
|
-
return (items && items[name]) || null;
|
50
|
-
}
|
51
|
-
set(type, name, instance) {
|
52
|
-
this.registry[type] = this.registry[type] || {};
|
53
|
-
this.registry[type][name] = instance;
|
54
|
-
return instance;
|
55
|
-
}
|
56
|
-
}
|
57
|
-
exports.DeployStack = DeployStack;
|
58
|
-
exports.default = DeployStack;
|
package/lib/DynamoDbTable.d.ts
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
import { Table } from 'aws-cdk-lib/aws-dynamodb';
|
2
|
-
import { Policy } from "aws-cdk-lib/aws-iam";
|
3
|
-
import { DeployStack } from "./DeployStack";
|
4
|
-
interface DynamoDbTableConfig {
|
5
|
-
partitionKey: string;
|
6
|
-
sortKey?: string;
|
7
|
-
}
|
8
|
-
export declare class DynamoDbTable extends Table {
|
9
|
-
getPolicy: Policy;
|
10
|
-
constructor(stack: DeployStack, id: string, props: DynamoDbTableConfig);
|
11
|
-
}
|
12
|
-
export {};
|
package/lib/DynamoDbTable.js
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.DynamoDbTable = void 0;
|
4
|
-
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
5
|
-
const aws_dynamodb_1 = require("aws-cdk-lib/aws-dynamodb");
|
6
|
-
const aws_iam_1 = require("aws-cdk-lib/aws-iam");
|
7
|
-
class DynamoDbTable extends aws_dynamodb_1.Table {
|
8
|
-
getPolicy;
|
9
|
-
constructor(stack, id, props) {
|
10
|
-
console.log('Creating DynamoDb Table', stack.genName(id, 'data-table'));
|
11
|
-
super(stack, stack.genId(id, 'data-table'), {
|
12
|
-
tableName: stack.genName(id, 'data-table'),
|
13
|
-
partitionKey: { name: props.partitionKey, type: aws_dynamodb_1.AttributeType.STRING },
|
14
|
-
sortKey: props.sortKey ? { name: props.sortKey, type: aws_dynamodb_1.AttributeType.STRING } : undefined,
|
15
|
-
billingMode: aws_dynamodb_1.BillingMode.PAY_PER_REQUEST,
|
16
|
-
removalPolicy: aws_cdk_lib_1.RemovalPolicy.DESTROY
|
17
|
-
});
|
18
|
-
stack.set('dynamo', id, this);
|
19
|
-
new aws_cdk_lib_1.CfnOutput(stack, stack.genId(id, 'table'), {
|
20
|
-
value: this.tableName,
|
21
|
-
exportName: stack.genName(id, 'table')
|
22
|
-
});
|
23
|
-
this.getPolicy = new aws_iam_1.Policy(stack, stack.genId(id, 'get-policy'), {
|
24
|
-
statements: [
|
25
|
-
new aws_iam_1.PolicyStatement({
|
26
|
-
actions: ['dynamodb:GetItem'],
|
27
|
-
effect: aws_iam_1.Effect.ALLOW,
|
28
|
-
resources: [this.tableArn]
|
29
|
-
})
|
30
|
-
]
|
31
|
-
});
|
32
|
-
}
|
33
|
-
}
|
34
|
-
exports.DynamoDbTable = DynamoDbTable;
|
@@ -1,25 +0,0 @@
|
|
1
|
-
import { DeployStack } from "./DeployStack";
|
2
|
-
import { Function, FunctionProps } from "aws-cdk-lib/aws-lambda";
|
3
|
-
import { JsonSchema, MethodOptions, Method } from "aws-cdk-lib/aws-apigateway";
|
4
|
-
import { Duration } from "aws-cdk-lib";
|
5
|
-
import { RestApi } from "./RestApi";
|
6
|
-
interface AddToApiOptions {
|
7
|
-
requestSchema?: JsonSchema;
|
8
|
-
methodOptions?: MethodOptions;
|
9
|
-
}
|
10
|
-
export interface FunctionIntegrationProps {
|
11
|
-
funcProps: FunctionProps;
|
12
|
-
timeout?: Duration;
|
13
|
-
memory?: number;
|
14
|
-
}
|
15
|
-
export declare class FunctionIntegration extends Function {
|
16
|
-
stack: DeployStack;
|
17
|
-
name: string;
|
18
|
-
constructor(stack: DeployStack, id: string, options: FunctionIntegrationProps);
|
19
|
-
attach(api: RestApi, httpMethod: string, path: string, props?: AddToApiOptions): ApiAttachPoint;
|
20
|
-
}
|
21
|
-
interface ApiAttachPoint {
|
22
|
-
method: Method;
|
23
|
-
resourceArn: string;
|
24
|
-
}
|
25
|
-
export {};
|
@@ -1,65 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.FunctionIntegration = void 0;
|
4
|
-
const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
|
5
|
-
const aws_apigateway_1 = require("aws-cdk-lib/aws-apigateway");
|
6
|
-
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
7
|
-
const apply_honeycomb_to_lambda_1 = require("./methods/apply-honeycomb-to-lambda");
|
8
|
-
const aws_logs_1 = require("aws-cdk-lib/aws-logs");
|
9
|
-
class FunctionIntegration extends aws_lambda_1.Function {
|
10
|
-
stack;
|
11
|
-
name;
|
12
|
-
constructor(stack, id, options) {
|
13
|
-
const props = (0, apply_honeycomb_to_lambda_1.applyHoneycombToLambda)(stack, {
|
14
|
-
functionName: stack.genName(id),
|
15
|
-
memorySize: options.memory || 256,
|
16
|
-
timeout: options.timeout || aws_cdk_lib_1.Duration.seconds(16),
|
17
|
-
logRetention: aws_logs_1.RetentionDays.ONE_WEEK,
|
18
|
-
...options.funcProps
|
19
|
-
});
|
20
|
-
super(stack, stack.genId(id, 'lambda'), props);
|
21
|
-
this.stack = stack;
|
22
|
-
this.name = id;
|
23
|
-
stack.set('lambda', id, this);
|
24
|
-
new aws_cdk_lib_1.CfnOutput(stack, stack.genId(id, 'function-name'), {
|
25
|
-
value: this.functionName,
|
26
|
-
exportName: stack.genName(id, 'function-name')
|
27
|
-
});
|
28
|
-
}
|
29
|
-
attach(api, httpMethod, path, props = {}) {
|
30
|
-
const resource = api.path(path);
|
31
|
-
const integration = new aws_apigateway_1.LambdaIntegration(this, {
|
32
|
-
requestTemplates: {
|
33
|
-
'application/json': '{ "statusCode": "200" }'
|
34
|
-
}
|
35
|
-
});
|
36
|
-
let options = props?.methodOptions || {};
|
37
|
-
const schema = props?.requestSchema;
|
38
|
-
if (schema)
|
39
|
-
options = applySchema(this.stack, this.name, schema, options, resource);
|
40
|
-
const method = resource.addMethod(httpMethod, integration, options);
|
41
|
-
return {
|
42
|
-
method,
|
43
|
-
resourceArn: `arn:aws:execute-api:${this.stack.region}:${this.stack.account}:${api.restApiId}/${this.stack.stage}/${httpMethod}${path}`
|
44
|
-
};
|
45
|
-
}
|
46
|
-
}
|
47
|
-
exports.FunctionIntegration = FunctionIntegration;
|
48
|
-
function applySchema(stack, name, schema, options, path) {
|
49
|
-
return {
|
50
|
-
...options,
|
51
|
-
requestValidator: new aws_apigateway_1.RequestValidator(stack, stack.genId(name, 'validator'), {
|
52
|
-
restApi: path.api,
|
53
|
-
requestValidatorName: stack.genName(name, 'validator'),
|
54
|
-
validateRequestBody: true
|
55
|
-
}),
|
56
|
-
requestModels: {
|
57
|
-
'application/json': new aws_apigateway_1.Model(stack, stack.genId(name, 'model'), {
|
58
|
-
schema: schema,
|
59
|
-
contentType: 'application/json',
|
60
|
-
restApi: path.api,
|
61
|
-
modelName: stack.genId(name, 'model')
|
62
|
-
})
|
63
|
-
}
|
64
|
-
};
|
65
|
-
}
|
package/lib/ICorsConfig.d.ts
DELETED
package/lib/IDeployStack.d.ts
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
import { Stack } from 'aws-cdk-lib';
|
2
|
-
import IStackArguments from './IStackArguments';
|
3
|
-
import { IConstruct } from "constructs";
|
4
|
-
export declare class IDeployStack extends Stack {
|
5
|
-
registry: {
|
6
|
-
[t: string]: {
|
7
|
-
[n: string]: any;
|
8
|
-
};
|
9
|
-
};
|
10
|
-
stage: string;
|
11
|
-
name: string;
|
12
|
-
genName(...name: string[]): string;
|
13
|
-
genId(...name: string[]): string;
|
14
|
-
static genStackResourceName(stackName: string, resource: string, stage?: string): string;
|
15
|
-
static genStackResourceId(stackName: string, resource: string, stage?: string): string;
|
16
|
-
constructor(scope: IConstruct, props: IStackArguments);
|
17
|
-
get(type: string, name: string): any;
|
18
|
-
set(type: string, name: string, instance: any): any;
|
19
|
-
}
|
20
|
-
export default IDeployStack;
|
package/lib/IDeployStack.js
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.IDeployStack = void 0;
|
4
|
-
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
5
|
-
class IDeployStack extends aws_cdk_lib_1.Stack {
|
6
|
-
registry = {};
|
7
|
-
stage;
|
8
|
-
name;
|
9
|
-
genName(...name) {
|
10
|
-
return IDeployStack.genStackResourceName(this.name, this.stage, name.filter(n => !!n).join('-'));
|
11
|
-
}
|
12
|
-
genId(...name) {
|
13
|
-
return IDeployStack.genStackResourceId(this.name, this.stage, name.filter(n => !!n).join('-'));
|
14
|
-
}
|
15
|
-
static genStackResourceName(stackName, resource, stage = 'develop') {
|
16
|
-
let name = stackName[0].toLowerCase() + stackName.substr(1);
|
17
|
-
name = name.replace(/[A-Z]/g, v => '-' + v.toLowerCase());
|
18
|
-
return `${name}-${resource}-${stage}`.toLowerCase();
|
19
|
-
}
|
20
|
-
static genStackResourceId(stackName, resource, stage = 'develop') {
|
21
|
-
const constructName = `${stackName}-${resource}-${stage}`;
|
22
|
-
return constructName[0].toUpperCase() + constructName.substr(1).replace(/-./g, v => (v[1] || '').toUpperCase());
|
23
|
-
}
|
24
|
-
constructor(scope, props) {
|
25
|
-
const options = (props || {});
|
26
|
-
const { stage = 'develop' } = options;
|
27
|
-
super(scope, props.stackName + '-' + stage, {
|
28
|
-
...props,
|
29
|
-
stackName: props.stackName + '-' + stage
|
30
|
-
});
|
31
|
-
const stack = this;
|
32
|
-
stack.name = props.stackName || '';
|
33
|
-
stack.stage = stage;
|
34
|
-
stack.tags.setTag('Stage', stage);
|
35
|
-
stack.tags.setTag('Stack', this.genName('ui-stack'));
|
36
|
-
}
|
37
|
-
get(type, name) {
|
38
|
-
const items = this.registry[type];
|
39
|
-
return (items && items[name]) || null;
|
40
|
-
}
|
41
|
-
set(type, name, instance) {
|
42
|
-
this.registry[type] = this.registry[type] || {};
|
43
|
-
this.registry[type][name] = instance;
|
44
|
-
return instance;
|
45
|
-
}
|
46
|
-
}
|
47
|
-
exports.IDeployStack = IDeployStack;
|
48
|
-
exports.default = IDeployStack;
|
package/lib/IDomainConfig.d.ts
DELETED
package/lib/IDomainConfig.js
DELETED
package/lib/IHostedZoneConfig.js
DELETED
package/lib/IStackArguments.d.ts
DELETED
package/lib/IStackArguments.js
DELETED
package/lib/NodeJsLambda.d.ts
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
import { FunctionOptions } from "aws-cdk-lib/aws-lambda";
|
2
|
-
import { DeployStack } from "./DeployStack";
|
3
|
-
import { FunctionIntegration } from "./FunctionIntegration";
|
4
|
-
import { Duration } from "aws-cdk-lib";
|
5
|
-
interface NodeFunctionProps {
|
6
|
-
funcProps?: FunctionOptions;
|
7
|
-
timeout?: Duration;
|
8
|
-
memory?: number;
|
9
|
-
}
|
10
|
-
export declare class NodeJsLambda extends FunctionIntegration {
|
11
|
-
constructor(stack: DeployStack, id: string, options?: NodeFunctionProps);
|
12
|
-
}
|
13
|
-
export {};
|
package/lib/NodeJsLambda.js
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.NodeJsLambda = void 0;
|
7
|
-
const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
|
8
|
-
const FunctionIntegration_1 = require("./FunctionIntegration");
|
9
|
-
const build_node_source_1 = require("./methods/build-node-source");
|
10
|
-
const duration_1 = __importDefault(require("./methods/duration"));
|
11
|
-
class NodeJsLambda extends FunctionIntegration_1.FunctionIntegration {
|
12
|
-
constructor(stack, id, options) {
|
13
|
-
console.log('Defining Node Lambda', id);
|
14
|
-
const done = (0, duration_1.default)();
|
15
|
-
const { buildDir } = (0, build_node_source_1.buildNodeSource)('lambda', id);
|
16
|
-
console.log('Total Build Duration (ms)', done());
|
17
|
-
super(stack, id, {
|
18
|
-
...options,
|
19
|
-
funcProps: {
|
20
|
-
...options?.funcProps,
|
21
|
-
code: aws_lambda_1.Code.fromAsset(buildDir),
|
22
|
-
handler: `${id}.handler`,
|
23
|
-
runtime: aws_lambda_1.Runtime.NODEJS_18_X
|
24
|
-
}
|
25
|
-
});
|
26
|
-
}
|
27
|
-
}
|
28
|
-
exports.NodeJsLambda = NodeJsLambda;
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import { LayerVersion, Runtime } from "aws-cdk-lib/aws-lambda";
|
2
|
-
import { DeployStack } from "./DeployStack";
|
3
|
-
import { LayerVersionOptions } from "aws-cdk-lib/aws-lambda/lib/layers";
|
4
|
-
import { Architecture } from "aws-cdk-lib/aws-lambda/lib/architecture";
|
5
|
-
interface NodeJsLambdaLayerProps extends LayerVersionOptions {
|
6
|
-
readonly compatibleRuntimes?: Runtime[];
|
7
|
-
readonly compatibleArchitectures?: Architecture[];
|
8
|
-
}
|
9
|
-
export declare class NodeJsLambdaLayer extends LayerVersion {
|
10
|
-
constructor(stack: DeployStack, id: string, props?: NodeJsLambdaLayerProps);
|
11
|
-
}
|
12
|
-
export {};
|
package/lib/NodeJsLambdaLayer.js
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.NodeJsLambdaLayer = void 0;
|
7
|
-
const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
|
8
|
-
const build_node_source_1 = require("./methods/build-node-source");
|
9
|
-
const duration_1 = __importDefault(require("./methods/duration"));
|
10
|
-
class NodeJsLambdaLayer extends aws_lambda_1.LayerVersion {
|
11
|
-
constructor(stack, id, props = {}) {
|
12
|
-
console.log("Building Lambda Layer", id);
|
13
|
-
const done = (0, duration_1.default)();
|
14
|
-
const { buildDir } = (0, build_node_source_1.buildNodeSource)('lambda-layer', id, { dir: 'nodejs' });
|
15
|
-
console.log('Build Duration (ms)', done());
|
16
|
-
super(stack, stack.genId(id), {
|
17
|
-
...props,
|
18
|
-
layerVersionName: stack.genName(id),
|
19
|
-
code: aws_lambda_1.Code.fromAsset(buildDir)
|
20
|
-
});
|
21
|
-
stack.set('lambda-layer', id, this);
|
22
|
-
}
|
23
|
-
}
|
24
|
-
exports.NodeJsLambdaLayer = NodeJsLambdaLayer;
|
package/lib/Output.d.ts
DELETED
package/lib/Output.js
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.Output = void 0;
|
4
|
-
const core_1 = require("aws-cdk-lib/core");
|
5
|
-
class Output extends core_1.CfnOutput {
|
6
|
-
constructor(stack, name, value) {
|
7
|
-
super(stack, stack.genId(name, 'output'), {
|
8
|
-
value,
|
9
|
-
exportName: stack.genName(name)
|
10
|
-
});
|
11
|
-
}
|
12
|
-
}
|
13
|
-
exports.Output = Output;
|
package/lib/RestApi.d.ts
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
import { IDomainName, IResource, RestApi as RestApiBase } from "aws-cdk-lib/aws-apigateway";
|
2
|
-
import { DeployStack } from "./DeployStack";
|
3
|
-
import { ICorsConfig } from "./ICorsConfig";
|
4
|
-
import { PolicyStatement } from "aws-cdk-lib/aws-iam";
|
5
|
-
interface IRestApiConfig {
|
6
|
-
cors?: ICorsConfig;
|
7
|
-
allowCredentials: boolean;
|
8
|
-
}
|
9
|
-
interface IBasePathMappingConfig {
|
10
|
-
domain?: IDomainName;
|
11
|
-
domainName?: string;
|
12
|
-
hostedZoneId?: string;
|
13
|
-
}
|
14
|
-
interface IResourceNode {
|
15
|
-
children: {
|
16
|
-
[key: string]: IResourceNode;
|
17
|
-
};
|
18
|
-
node: IResource;
|
19
|
-
}
|
20
|
-
export declare class RestApi extends RestApiBase {
|
21
|
-
_id: string;
|
22
|
-
_tree: IResourceNode;
|
23
|
-
constructor(stack: DeployStack, id: string, props: IRestApiConfig);
|
24
|
-
addBasePathMapping(stack: DeployStack, config: IBasePathMappingConfig): void;
|
25
|
-
addAuthorizedRole(stack: DeployStack, roleArn: string): PolicyStatement;
|
26
|
-
path(uri: string): IResource;
|
27
|
-
}
|
28
|
-
export {};
|
package/lib/Role.js
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.Role = void 0;
|
4
|
-
const aws_iam_1 = require("aws-cdk-lib/aws-iam");
|
5
|
-
const Output_1 = require("./Output");
|
6
|
-
class Role extends aws_iam_1.Role {
|
7
|
-
constructor(stack, id, props) {
|
8
|
-
console.log('Defining Role', stack.genId(id));
|
9
|
-
if (!props.assumedBy) {
|
10
|
-
props.assumedBy = new aws_iam_1.FederatedPrincipal('cognito-identity.amazonaws.com', {
|
11
|
-
StringEquals: {
|
12
|
-
'cognito-identity.amazonaws.com:aud': props.identityPool
|
13
|
-
},
|
14
|
-
"ForAnyValue:StringLike": {
|
15
|
-
'cognito-identity.amazonaws.com:amr': props.amr
|
16
|
-
}
|
17
|
-
}, 'sts:AssumeRoleWithWebIdentity');
|
18
|
-
}
|
19
|
-
super(stack, stack.genId(id), {
|
20
|
-
...props,
|
21
|
-
roleName: stack.genName(props.roleName || id),
|
22
|
-
assumedBy: props.assumedBy
|
23
|
-
});
|
24
|
-
new Output_1.Output(stack, `${id}-arn`, this.roleArn);
|
25
|
-
}
|
26
|
-
}
|
27
|
-
exports.Role = Role;
|
package/lib/SsmParameter.d.ts
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
import { DeployStack } from "./DeployStack";
|
2
|
-
import { IStringParameter } from "aws-cdk-lib/aws-ssm";
|
3
|
-
import { IGrantable } from "aws-cdk-lib/aws-iam";
|
4
|
-
import { IKey } from "aws-cdk-lib/aws-kms";
|
5
|
-
export interface SsmParameterOptions {
|
6
|
-
decryptWithKey?: IKey;
|
7
|
-
parameterGroup?: string;
|
8
|
-
}
|
9
|
-
export declare class SsmParameter {
|
10
|
-
parameterName: string;
|
11
|
-
parameterArn: string;
|
12
|
-
decryptWithKey?: IKey;
|
13
|
-
_stack: DeployStack;
|
14
|
-
constructor(stack: DeployStack, name: string, options?: SsmParameterOptions);
|
15
|
-
grantRead(grantee: IGrantable): void;
|
16
|
-
get stringValue(): string;
|
17
|
-
getParameter(): IStringParameter;
|
18
|
-
}
|
package/lib/SsmParameter.js
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.SsmParameter = void 0;
|
4
|
-
const aws_ssm_1 = require("aws-cdk-lib/aws-ssm");
|
5
|
-
const aws_iam_1 = require("aws-cdk-lib/aws-iam");
|
6
|
-
const paramCache = {};
|
7
|
-
class SsmParameter {
|
8
|
-
parameterName;
|
9
|
-
parameterArn;
|
10
|
-
decryptWithKey;
|
11
|
-
_stack;
|
12
|
-
constructor(stack, name, options) {
|
13
|
-
if (name[0] !== '/')
|
14
|
-
name = '/' + name;
|
15
|
-
this.parameterName = `/${options?.parameterGroup ?? stack.name}${name}`;
|
16
|
-
this.parameterArn = `arn:aws:ssm:${stack.region}:${stack.account}:parameter${this.parameterName}`;
|
17
|
-
this._stack = stack;
|
18
|
-
this.decryptWithKey = options?.decryptWithKey;
|
19
|
-
}
|
20
|
-
grantRead(grantee) {
|
21
|
-
grantee.grantPrincipal.addToPrincipalPolicy(new aws_iam_1.PolicyStatement({
|
22
|
-
effect: aws_iam_1.Effect.ALLOW,
|
23
|
-
actions: ['ssm:GetParameter'],
|
24
|
-
resources: [this.parameterArn]
|
25
|
-
}));
|
26
|
-
if (this.decryptWithKey) {
|
27
|
-
this.decryptWithKey.grantDecrypt(grantee);
|
28
|
-
}
|
29
|
-
}
|
30
|
-
get stringValue() {
|
31
|
-
return this.getParameter().stringValue;
|
32
|
-
}
|
33
|
-
getParameter() {
|
34
|
-
if (!paramCache[this.parameterArn]) {
|
35
|
-
paramCache[this.parameterArn] = aws_ssm_1.StringParameter.fromStringParameterName(this._stack, this._stack.genId(this.parameterName.substring(1).replace('/', '_')), this.parameterName);
|
36
|
-
}
|
37
|
-
return paramCache[this.parameterArn];
|
38
|
-
}
|
39
|
-
}
|
40
|
-
exports.SsmParameter = SsmParameter;
|
package/lib/StaticWebSite.d.ts
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
import { DeployStack } from "./DeployStack";
|
3
|
-
import { SourceConfiguration } from "aws-cdk-lib/aws-cloudfront";
|
4
|
-
import IDomainConfig from "./IDomainConfig";
|
5
|
-
import { IIgnoreOptions } from "./methods/walk-directory";
|
6
|
-
interface StaticWebSiteConfig {
|
7
|
-
srcDir?: string;
|
8
|
-
domain: IDomainConfig;
|
9
|
-
env: NodeJS.ProcessEnv;
|
10
|
-
ignore?: IIgnoreOptions;
|
11
|
-
proxy?: SourceConfiguration[];
|
12
|
-
}
|
13
|
-
export declare class StaticWebSite {
|
14
|
-
constructor(stack: DeployStack, id: string, props: StaticWebSiteConfig);
|
15
|
-
static defineProxy(stack: DeployStack, domainName: string, pathPattern: string): SourceConfiguration;
|
16
|
-
}
|
17
|
-
export {};
|