@bifravst/aws-cdk-lambda-helpers 1.4.5 → 1.5.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/dist/src/PackedLambdaFn.d.ts +23 -0
- package/dist/src/PackedLambdaFn.js +49 -0
- package/dist/src/cdk.d.ts +1 -0
- package/dist/src/cdk.js +1 -0
- package/package.json +2 -1
@@ -0,0 +1,23 @@
|
|
1
|
+
import { aws_lambda as Lambda } from 'aws-cdk-lib';
|
2
|
+
import { Construct } from 'constructs';
|
3
|
+
import type { PackedLambda } from './packLambda.js';
|
4
|
+
/**
|
5
|
+
* Creates a Lambda function with useful defaults:
|
6
|
+
*
|
7
|
+
* - Code from a PackedLambda
|
8
|
+
* - Architecture: ARM64
|
9
|
+
* - Runtime: Node.js 20
|
10
|
+
* - timeout: 5 seconds
|
11
|
+
* - memorySize: 1792 MB
|
12
|
+
* - environment
|
13
|
+
* VERSION: set from the 'version' context
|
14
|
+
* NODE_NO_WARNINGS: disabled to get rid of Node.js warnings in the logs
|
15
|
+
* STACK_NAME: the current stack name
|
16
|
+
* DISABLE_METRICS: set to '1' of 'isTest'===true in the context
|
17
|
+
* - a LambdaLogGroup
|
18
|
+
* - policies that allow to access all SSM parameters below the current stack name
|
19
|
+
*/
|
20
|
+
export declare class PackedLambdaFn extends Construct {
|
21
|
+
readonly fn: Lambda.Function;
|
22
|
+
constructor(parent: Construct, id: string, source: PackedLambda, props: Partial<Omit<Lambda.FunctionProps, 'code' | 'handler'>>);
|
23
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { aws_lambda as Lambda, Duration, Stack } from 'aws-cdk-lib';
|
2
|
+
import { Construct } from 'constructs';
|
3
|
+
import { LambdaLogGroup } from './LambdaLogGroup.js';
|
4
|
+
import { Permissions as SettingsPermissions } from '@bifravst/aws-ssm-settings-helpers/cdk';
|
5
|
+
import { LambdaSource } from './LambdaSource.js';
|
6
|
+
/**
|
7
|
+
* Creates a Lambda function with useful defaults:
|
8
|
+
*
|
9
|
+
* - Code from a PackedLambda
|
10
|
+
* - Architecture: ARM64
|
11
|
+
* - Runtime: Node.js 20
|
12
|
+
* - timeout: 5 seconds
|
13
|
+
* - memorySize: 1792 MB
|
14
|
+
* - environment
|
15
|
+
* VERSION: set from the 'version' context
|
16
|
+
* NODE_NO_WARNINGS: disabled to get rid of Node.js warnings in the logs
|
17
|
+
* STACK_NAME: the current stack name
|
18
|
+
* DISABLE_METRICS: set to '1' of 'isTest'===true in the context
|
19
|
+
* - a LambdaLogGroup
|
20
|
+
* - policies that allow to access all SSM parameters below the current stack name
|
21
|
+
*/
|
22
|
+
export class PackedLambdaFn extends Construct {
|
23
|
+
fn;
|
24
|
+
constructor(parent, id, source, props) {
|
25
|
+
super(parent, id);
|
26
|
+
const { environment, initialPolicy, ...rest } = props;
|
27
|
+
this.fn = new Lambda.Function(this, 'fn', {
|
28
|
+
architecture: Lambda.Architecture.ARM_64,
|
29
|
+
runtime: props.runtime ?? Lambda.Runtime.NODEJS_20_X,
|
30
|
+
timeout: Duration.seconds(5),
|
31
|
+
memorySize: 1792,
|
32
|
+
environment: {
|
33
|
+
VERSION: this.node.tryGetContext('version'),
|
34
|
+
NODE_NO_WARNINGS: '1',
|
35
|
+
STACK_NAME: Stack.of(this).stackName,
|
36
|
+
DISABLE_METRICS: this.node.tryGetContext('isTest') === true ? '1' : '0',
|
37
|
+
...environment,
|
38
|
+
},
|
39
|
+
initialPolicy: [
|
40
|
+
...(initialPolicy ?? []),
|
41
|
+
SettingsPermissions(Stack.of(this)),
|
42
|
+
],
|
43
|
+
...new LambdaLogGroup(this, 'fnLogs'),
|
44
|
+
...rest,
|
45
|
+
handler: source.handler,
|
46
|
+
code: new LambdaSource(this, source).code,
|
47
|
+
});
|
48
|
+
}
|
49
|
+
}
|
package/dist/src/cdk.d.ts
CHANGED
package/dist/src/cdk.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@bifravst/aws-cdk-lambda-helpers",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.5.0",
|
4
4
|
"description": "Helper functions which simplify working with TypeScript lambdas for AWS CDK.",
|
5
5
|
"exports": {
|
6
6
|
".": {
|
@@ -112,6 +112,7 @@
|
|
112
112
|
"yazl": "2.5.1"
|
113
113
|
},
|
114
114
|
"peerDependencies": {
|
115
|
+
"@bifravst/aws-ssm-settings-helpers": "^1.1.0",
|
115
116
|
"aws-cdk-lib": "^2.138.0",
|
116
117
|
"constructs": "^10.3.0"
|
117
118
|
}
|