@byaga/cdk-patterns 0.11.5 → 0.11.6
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/LICENSE.md +20 -20
- package/README.md +42 -42
- package/eslint.config.mjs +12 -0
- package/lib/build/copy-files.d.ts +4 -5
- package/lib/build/copy-files.js +26 -21
- package/lib/build/generate-hash.d.ts +2 -3
- package/lib/build/generate-hash.js +3 -5
- package/lib/build/get-files.d.ts +3 -3
- package/lib/build/get-files.js +3 -3
- package/lib/build/get-source-directory.d.ts +8 -8
- package/lib/build/get-source-directory.js +13 -13
- package/lib/build/hash-file.js +4 -5
- package/lib/build/index.d.ts +2 -0
- package/lib/build/index.js +21 -0
- package/lib/build/nodejs/build-ecmascript.d.ts +3 -3
- package/lib/build/nodejs/build-ecmascript.js +4 -5
- package/lib/build/nodejs/build-node-source.d.ts +9 -3
- package/lib/build/nodejs/build-node-source.js +10 -11
- package/lib/build/nodejs/build-typescript.d.ts +3 -3
- package/lib/build/nodejs/build-typescript.js +7 -10
- package/lib/build/nodejs/index.d.ts +1 -0
- package/lib/build/nodejs/index.js +5 -0
- package/lib/build/nodejs/install-node-modules.d.ts +4 -3
- package/lib/build/nodejs/install-node-modules.js +6 -6
- package/lib/cloud-formation/DeployStack.d.ts +11 -0
- package/lib/cloud-formation/DeployStack.js +2 -0
- package/lib/cloud-formation/create-stack.d.ts +20 -0
- package/lib/cloud-formation/create-stack.js +31 -0
- package/lib/cloud-formation/current-stack.d.ts +10 -0
- package/lib/cloud-formation/current-stack.js +19 -0
- package/lib/{generate-identifier.js → cloud-formation/generate-identifier.js} +7 -8
- package/lib/cloud-formation/index.d.ts +5 -0
- package/lib/cloud-formation/index.js +14 -0
- package/lib/cloud-formation/output.d.ts +2 -0
- package/lib/cloud-formation/output.js +12 -0
- package/lib/cloud-front/distribution.d.ts +16 -0
- package/lib/cloud-front/distribution.js +43 -0
- package/lib/cloud-front/index.d.ts +1 -0
- package/lib/cloud-front/index.js +5 -0
- package/lib/cloud-watch/create-log-group.js +4 -6
- package/lib/cloud-watch/index.d.ts +1 -0
- package/lib/cloud-watch/index.js +5 -0
- package/lib/cloud-watch/set-log-retention.d.ts +2 -0
- package/lib/cloud-watch/set-log-retention.js +14 -0
- package/lib/index.d.ts +11 -8
- package/lib/index.js +13 -29
- package/lib/lambda/create-function.d.ts +4 -2
- package/lib/lambda/create-function.js +15 -23
- package/lib/lambda/create-nodejs-lambda.d.ts +2 -2
- package/lib/lambda/create-nodejs-lambda.js +3 -4
- package/lib/lambda/index.d.ts +1 -0
- package/lib/lambda/index.js +5 -0
- package/lib/lambda-layer/apply-honeycomb-to-lambda.d.ts +1 -1
- package/lib/lambda-layer/apply-honeycomb-to-lambda.js +4 -5
- package/lib/lambda-layer/get-layer.js +4 -6
- package/lib/lambda-layer/index.d.ts +2 -0
- package/lib/lambda-layer/index.js +7 -0
- package/lib/lambda-layer/layer-cache.d.ts +3 -3
- package/lib/lambda-layer/layer-cache.js +3 -9
- package/lib/load-configuration.d.ts +3 -8
- package/lib/load-configuration.js +20 -11
- package/lib/recipes/ICorsConfig.d.ts +5 -0
- package/lib/recipes/ICorsConfig.js +2 -0
- package/lib/recipes/index.d.ts +1 -0
- package/lib/recipes/index.js +5 -0
- package/lib/recipes/staticWebSite.d.ts +13 -0
- package/lib/recipes/staticWebSite.js +54 -0
- package/lib/route53/IDomainConfig.d.ts +7 -0
- package/lib/route53/IDomainConfig.js +2 -0
- package/lib/route53/IHostedZoneConfig.d.ts +5 -0
- package/lib/route53/IHostedZoneConfig.js +2 -0
- package/lib/route53/apiCertificate.d.ts +13 -0
- package/lib/route53/apiCertificate.js +30 -0
- package/lib/route53/index.d.ts +3 -0
- package/lib/route53/index.js +5 -0
- package/lib/s3/bucket.d.ts +8 -0
- package/lib/s3/bucket.js +21 -0
- package/lib/s3/index.d.ts +1 -0
- package/lib/s3/index.js +5 -0
- package/lib/ssm/SsmParameter.d.ts +2 -2
- package/lib/ssm/StringParameter.d.ts +9 -0
- package/lib/ssm/StringParameter.js +15 -0
- package/lib/ssm/get-existing-parameter.js +4 -6
- package/lib/ssm/grant-read.js +1 -2
- package/lib/ssm/index.d.ts +1 -0
- package/lib/ssm/index.js +3 -1
- package/lib/ssm/parameter-cache.js +2 -3
- package/lib/ssm/string-value.js +1 -2
- package/lib/tools/index.d.ts +3 -0
- package/lib/tools/index.js +10 -0
- package/package.json +21 -15
- package/tsconfig.json +2 -2
- package/.fleet/run.json +0 -11
- package/archive/ApiAttachPoint.ts +0 -9
- package/archive/ApiCertificate.ts +0 -32
- package/archive/CognitoApiGatewayAuthorizer.ts +0 -25
- package/archive/DynamoDbTable.ts +0 -40
- package/archive/ICorsConfig.ts +0 -5
- package/archive/IDomainConfig.ts +0 -8
- package/archive/IHostedZoneConfig.ts +0 -5
- package/archive/NodeJsLambdaLayer.ts +0 -42
- package/archive/Output.ts +0 -11
- package/archive/RestApi.ts +0 -180
- package/archive/Role.ts +0 -165
- package/archive/StaticWebSite.ts +0 -158
- package/archive/index.ts +0 -18
- package/archive/methods/apply-schema-to-method-options.ts +0 -38
- package/archive/methods/attach-function-to-api.ts +0 -69
- package/lib/create-stack.d.ts +0 -40
- package/lib/create-stack.js +0 -48
- /package/lib/{generate-identifier.d.ts → cloud-formation/generate-identifier.d.ts} +0 -0
@@ -1,69 +0,0 @@
|
|
1
|
-
import {DeployStack} from "../DeployStack";
|
2
|
-
import {
|
3
|
-
JsonSchema,
|
4
|
-
LambdaIntegration,
|
5
|
-
MethodOptions,
|
6
|
-
IResource, Method
|
7
|
-
} from "aws-cdk-lib/aws-apigateway";
|
8
|
-
import {RestApi} from "../RestApi";
|
9
|
-
import {applySchemaToMethodOptions} from "./apply-schema-to-method-options";
|
10
|
-
import {FunctionIntegration} from "../create-function";
|
11
|
-
|
12
|
-
/**
|
13
|
-
* Type alias for the properties when attaching a function to an API or a resource.
|
14
|
-
*/
|
15
|
-
type AttachFunctionToApiProps = AttachFunctionToRestApiProps | AttachFunctionToResourceProps
|
16
|
-
|
17
|
-
/**
|
18
|
-
* Interface for the properties when attaching a function to an API.
|
19
|
-
*/
|
20
|
-
export interface AttachFunctionToRestApiProps {
|
21
|
-
api: RestApi
|
22
|
-
httpMethod: string
|
23
|
-
path: string
|
24
|
-
requestSchema?: JsonSchema,
|
25
|
-
methodOptions?: MethodOptions
|
26
|
-
}
|
27
|
-
|
28
|
-
/**
|
29
|
-
* Interface for the properties when attaching a function to a resource.
|
30
|
-
*/
|
31
|
-
export interface AttachFunctionToResourceProps {
|
32
|
-
resource: IResource
|
33
|
-
httpMethod: string
|
34
|
-
requestSchema?: JsonSchema,
|
35
|
-
methodOptions?: MethodOptions
|
36
|
-
}
|
37
|
-
|
38
|
-
export interface ApiAttachedFunction extends FunctionIntegration {
|
39
|
-
resourceArn: string
|
40
|
-
method: Method
|
41
|
-
}
|
42
|
-
|
43
|
-
/**
|
44
|
-
* Attaches a function to an API or a resource.
|
45
|
-
* @param {DeployStack} stack - The deployment stack.
|
46
|
-
* @param lambda - The Function that is being attached
|
47
|
-
* @param {AttachFunctionToApiProps} props - The properties for attaching the function.
|
48
|
-
* @returns {ApiAttachPoint} The API attach point.
|
49
|
-
*/
|
50
|
-
export function attachFunctionToApi(stack: DeployStack, lambda: FunctionIntegration, props: AttachFunctionToApiProps) : ApiAttachedFunction {
|
51
|
-
const resource: IResource = (props as AttachFunctionToResourceProps).resource || (props as AttachFunctionToRestApiProps).api.path((props as AttachFunctionToRestApiProps).path)
|
52
|
-
const integration = new LambdaIntegration(lambda.function, {
|
53
|
-
requestTemplates: {
|
54
|
-
'application/json': '{ "statusCode": "200" }'
|
55
|
-
}
|
56
|
-
})
|
57
|
-
|
58
|
-
let options: MethodOptions = props?.methodOptions || {}
|
59
|
-
const schema = props?.requestSchema
|
60
|
-
if (schema) options = applySchemaToMethodOptions(stack, lambda.id, schema, options, resource)
|
61
|
-
|
62
|
-
const method = resource.addMethod(props.httpMethod, integration, options)
|
63
|
-
|
64
|
-
return {
|
65
|
-
...lambda,
|
66
|
-
method,
|
67
|
-
resourceArn: `arn:aws:execute-api:${stack.region}:${stack.account}:${resource.api.restApiId}/${stack.stage}/${props.httpMethod}${resource.path}`
|
68
|
-
};
|
69
|
-
}
|
package/lib/create-stack.d.ts
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
import { IConstruct } from "constructs";
|
2
|
-
import { Stack } from "aws-cdk-lib";
|
3
|
-
import { StackProps } from "aws-cdk-lib/core";
|
4
|
-
import { StackConfiguration } from "./load-configuration";
|
5
|
-
/**
|
6
|
-
* Interface for the arguments when creating a stack.
|
7
|
-
*/
|
8
|
-
export interface StackArguments extends StackProps {
|
9
|
-
stackName: string;
|
10
|
-
stage?: string;
|
11
|
-
project: string;
|
12
|
-
owner: string;
|
13
|
-
region: string;
|
14
|
-
}
|
15
|
-
/**
|
16
|
-
* Interface for the stack.
|
17
|
-
*/
|
18
|
-
export interface DeployStack<T extends StackConfiguration> {
|
19
|
-
stack: Stack;
|
20
|
-
name: string;
|
21
|
-
stage: string;
|
22
|
-
project: string;
|
23
|
-
config: Partial<T>;
|
24
|
-
}
|
25
|
-
/**
|
26
|
-
* Creates a new stack.
|
27
|
-
* @param {IConstruct} scope - The scope in which to define this construct.
|
28
|
-
* @param {StackArguments} props - The arguments for creating the stack.
|
29
|
-
* @returns {DeployStack} The created stack.
|
30
|
-
*/
|
31
|
-
export declare function createStack<T extends StackConfiguration>(scope: IConstruct, props: StackArguments): DeployStack<T>;
|
32
|
-
/**
|
33
|
-
* Helpful method to get the 'current' stack that is being defined. Hopefully this will reduce the need to pass the stack around everywhere.
|
34
|
-
*/
|
35
|
-
export declare function getCurrentStack<T extends StackConfiguration>(): DeployStack<T>;
|
36
|
-
/**
|
37
|
-
* This sets the 'current' stack. This should be automatic everywhere, but in case something goes wrong here is a way to force the issue
|
38
|
-
* @param stack
|
39
|
-
*/
|
40
|
-
export declare function setCurrentStack<T extends StackConfiguration>(stack: DeployStack<T>): DeployStack<T>;
|
package/lib/create-stack.js
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.setCurrentStack = exports.getCurrentStack = exports.createStack = void 0;
|
4
|
-
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
5
|
-
const generate_identifier_1 = require("./generate-identifier");
|
6
|
-
const load_configuration_1 = require("./load-configuration");
|
7
|
-
/**
|
8
|
-
* Creates a new stack.
|
9
|
-
* @param {IConstruct} scope - The scope in which to define this construct.
|
10
|
-
* @param {StackArguments} props - The arguments for creating the stack.
|
11
|
-
* @returns {DeployStack} The created stack.
|
12
|
-
*/
|
13
|
-
function createStack(scope, props) {
|
14
|
-
const { stage = 'develop' } = props;
|
15
|
-
const stack = new aws_cdk_lib_1.Stack(scope, (0, generate_identifier_1.genId)(props.stackName, stage), {
|
16
|
-
...props,
|
17
|
-
stackName: (0, generate_identifier_1.genName)(props.stackName, stage)
|
18
|
-
});
|
19
|
-
stack.tags.setTag('stage', stage);
|
20
|
-
stack.tags.setTag('stack', (0, generate_identifier_1.genName)(props.stackName, stage));
|
21
|
-
stack.tags.setTag('project', props.project);
|
22
|
-
stack.tags.setTag('owner', props.owner);
|
23
|
-
return setCurrentStack({
|
24
|
-
stack,
|
25
|
-
name: props.stackName,
|
26
|
-
stage,
|
27
|
-
project: props.project,
|
28
|
-
config: (0, load_configuration_1.loadConfiguration)(stage)
|
29
|
-
});
|
30
|
-
}
|
31
|
-
exports.createStack = createStack;
|
32
|
-
let currentStack;
|
33
|
-
/**
|
34
|
-
* Helpful method to get the 'current' stack that is being defined. Hopefully this will reduce the need to pass the stack around everywhere.
|
35
|
-
*/
|
36
|
-
function getCurrentStack() {
|
37
|
-
return currentStack;
|
38
|
-
}
|
39
|
-
exports.getCurrentStack = getCurrentStack;
|
40
|
-
/**
|
41
|
-
* This sets the 'current' stack. This should be automatic everywhere, but in case something goes wrong here is a way to force the issue
|
42
|
-
* @param stack
|
43
|
-
*/
|
44
|
-
function setCurrentStack(stack) {
|
45
|
-
currentStack = stack;
|
46
|
-
return stack;
|
47
|
-
}
|
48
|
-
exports.setCurrentStack = setCurrentStack;
|
File without changes
|