cdk-lambda-code
v0.2.0
Published
Wrapper arroud @aws-cdk/aws-lambda Code to support mocking in test mode and configuration wtih package.json namespaces
Downloads
3
Readme
cdk-lambda-code
Wrapper arroud @aws-cdk/aws-lambda Code to support mocking in test mode and configuration wtih package.json namespaces
:warning: This is experimental and subject to breaking changes.
Install
// with npm
npm install cdk-lambda-code
// with yarn
yarn add cdk-lambda-code
How to use fromPackageJson
// package.json
{
"name": "construct",
"lambdaDependencies": {
"lambdaHandler": {
"runtime": "nodejs10.x",
"handler": "lib/index.handler",
"artifact": "lambda/bundle.zip"
}
}
}
// smaple-construct.ts
import { LambdaCode } from 'cdk-lambda-code';
new Function(this, 'LambdaFunction', {
...LambdaCode.fromPackageJson('lambdaHandler', {
cwd: __dirname,
mockInTestMode: true
})
});
How to use fromFileAsInline
// smaple-construct.ts
import { LambdaCode } from 'cdk-lambda-code';
new Function(this, 'LambdaFunction', {
code: LambdaCode.fromFileAsInline(path.join(__dirname, '..', 'handler.js'))
runtime: Runtime.NODEJS_10_X,
handler: 'index.handler'
});