@byaga/cdk-patterns 0.8.0 → 0.8.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byaga/cdk-patterns",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Collection of common patterns used when making AWS CloudFormation templates using CDK",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -47,7 +47,7 @@ export class FunctionIntegration extends Function {
47
47
  });
48
48
  }
49
49
 
50
- attach(api: RestApi, httpMethod: string, path: string, props: AddToApiOptions) {
50
+ attach(api: RestApi, httpMethod: string, path: string, props?: AddToApiOptions) {
51
51
  const resource: IResource = api.path(path)
52
52
  const integration = new LambdaIntegration(this, {
53
53
  requestTemplates: {
@@ -0,0 +1,27 @@
1
+ import {Code, LayerVersion, Runtime} from "aws-cdk-lib/aws-lambda";
2
+ import {IDeployStack} from "./IDeployStack";
3
+ import {LayerVersionOptions} from "aws-cdk-lib/aws-lambda/lib/layers";
4
+ import {Architecture} from "aws-cdk-lib/aws-lambda/lib/architecture";
5
+ import {buildNodeSource} from "./methods/build-node-source";
6
+ import duration from "./methods/duration";
7
+
8
+ interface NodeJsLambdaLayerProps extends LayerVersionOptions {
9
+ readonly compatibleRuntimes?: Runtime[];
10
+ readonly compatibleArchitectures?: Architecture[];
11
+ }
12
+
13
+ export class NodeJsLambdaLayer extends LayerVersion {
14
+ constructor(stack: IDeployStack, id: string, props: NodeJsLambdaLayerProps = {}) {
15
+ console.log("Building Lambda Layer", id);
16
+ const done = duration()
17
+ const buildDir = buildNodeSource('lambda-layer', id, 'nodejs')
18
+ console.log('Build Duration (ms)', done())
19
+
20
+ super(stack, stack.genId(id), {
21
+ ...props,
22
+ layerVersionName: stack.genName(id),
23
+ code: Code.fromAsset(buildDir)
24
+ });
25
+ stack.set('lambda-layer', id, this)
26
+ }
27
+ }
package/src/index.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  export {ApiCertificate} from "./ApiCertificate";
2
2
  export {DeployStack} from "./DeployStack";
3
- export {IDomainConfig} from "./IDomainConfig";
3
+ export {DynamoDbTable} from "./DynamoDbTable";
4
+ export {FunctionIntegration} from "./FunctionIntegration";
4
5
  export {IHostedZoneConfig} from "./IHostedZoneConfig";
6
+ export {IDomainConfig} from "./IDomainConfig";
5
7
  export {IStackArguments} from "./IStackArguments";
6
- export {Role} from "./Role";
7
- export {StaticWebSite} from "./StaticWebSite";
8
+ export {NodeJsLambda} from "./NodeJsLambda";
9
+ export {NodeJsLambdaLayer} from "./NodeJsLambdaLayer";
8
10
  export {Output} from "./Output";
9
11
  export {RestApi} from "./RestApi";
10
- export {NodeJsLambda} from "./NodeJsLambda";
11
- export {DynamoDbTable} from "./DynamoDbTable";
12
- export {FunctionIntegration} from "./FunctionIntegration";
12
+ export {Role} from "./Role";
13
+ export {SsmParameter} from "./SsmParameter";
14
+ export {StaticWebSite} from "./StaticWebSite";