A simple wrapper for the NodejsFunction
construct that enables the Powertools Layer.
The construct aims to be a drop-in replacement to the NodejsFunction
. The only thing that has to be adjusted is, that
the function calls to the NodejsFunction
has to be on the property fn
from the NodejsWithPowertoolsFunction
.
import { NodejsWithPowertoolsFunction } from 'nodejs-with-powertools-function';
class MyStack extends Stack {
constructor(scope: Construct, id: string) {
super(scope, id);
const myFunction = new NodejsWithPowertoolsFunction(this, 'PowertoolsFunction', {
entry: __dirname + '/my-lambda-function.ts',
powertoolsVersion: '10',
powertoolsEnvironmentVariables: {
POWERTOOLS_SERVICE_NAME: 'my-cool-service'
}
});
myFunction.fn.addToRolePolicy(
new PolicyStatement({
actions: ['kms:*'],
resources: ['*'],
effect: Effect.ALLOW,
}));
}
}
To use this construct, the AWS CDK has to be installed.
npm i aws-cdk-lib
To install the construct, just install it with your favorite package manager from the npm registry:
npm i nodejs-with-powertools-function
- projen - The project generation tool
This project is licensed under the Apache 2.0 License - see the LICENSE file for details