hupe1980 / cdk-lambda-code

Wrapper arroud @aws-cdk/aws-lambda Code to support mocking in test mode and configuration wtih package.json namespaces

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cdk-lambda-code

Build Status

Wrapper arroud @aws-cdk/aws-lambda Code to support mocking in test mode and configuration wtih package.json namespaces

⚠️ 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'
});

License

MIT

About

Wrapper arroud @aws-cdk/aws-lambda Code to support mocking in test mode and configuration wtih package.json namespaces

License:MIT License


Languages

Language:TypeScript 99.2%Language:JavaScript 0.8%