Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hupe1980/cdk-lambda-code

Wrapper arroud @aws-cdk/aws-lambda Code to support mocking in test mode and configuration wtih package.json namespaces
https://github.com/hupe1980/cdk-lambda-code

aws cdk lambda

Last synced: about 1 month ago
JSON representation

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

Awesome Lists containing this project

README

        

# cdk-lambda-code

[![Build Status](https://travis-ci.org/hupe1980/cdk-lambda-code.svg?branch=master)](https://travis-ci.org/hupe1980/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

```sh
// with npm
npm install cdk-lambda-code

// with yarn
yarn add cdk-lambda-code
```

## How to use `fromPackageJson`

```json
// package.json

{
"name": "construct",
"lambdaDependencies": {
"lambdaHandler": {
"runtime": "nodejs10.x",
"handler": "lib/index.handler",
"artifact": "lambda/bundle.zip"
}
}
}
```

```typescript
// smaple-construct.ts
import { LambdaCode } from 'cdk-lambda-code';

new Function(this, 'LambdaFunction', {
...LambdaCode.fromPackageJson('lambdaHandler', {
cwd: __dirname,
mockInTestMode: true
})
});
```

## How to use `fromFileAsInline`

```typescript
// 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](LICENSE)