AWS Lambda Microservices Architecture for Node.js

Repack Lambda

While this project template is designed for Node.js, it can be used for Java or Python with just small changes.

This architecture is not recommended for long running jobs, the max timeout is 300 seconds.

Microservices Architecture with AWS Lambda

Features:

Develop multiple lambda functions over the same code base

Scaffold new lambda functions (configs, handlers & tests)

One command deploy (build, lint, test & deploy)

Webpack build system for production

Use ES2015 & Babel

Use Mocha for tests

Travis for CI

Use ESLint

Easy versioning & release

Focus on modularity

Install

PROTIP Be sure to using the latest Node.js LTS Version.

$ npm install

Project Structure

All available commands are defined as scripts in packages.json

.

├── LICENSE

├── README.md

├── bin

│ ├── build.sh

│ ├── create.sh

│ └── deploy.sh

├── config

│ └── templates

│ ├── lambda-spec.tpl.js - Spec test template

│ ├── lambda.config.tpl.js - Lambda config template

│ └── lambda.tpl.js - Lambda handler template

├── gulpfile.js

├── package.json

├── src

│ └── lambdas

├── tests

│ └── index-spec.js

└── webpack.config.js

Quick Start

$ APP=myLambda npm run create

This command will create 3 files:

./src/lambdas/myLambda.js — Lambda handler function ./tests/myLambda-spec.js — Function test file with Mocha ./config/myLambda.config.js — Lambda config file

Tests

This will run all tests for all lambda functions.

$ npm test

You can run without npm too:

$ mocha ./tests/myLambda-spec.js --compilers js:babel-register

PROTIP If do you choose run it without npm please install mocha as global before

$ npm install mocha babel-cli babel-register -g

Deploy

Before deploy you have to get the AWS Lambda Role Arn

$ ROLE_ARN=xxxx APP=myLambda npm run deployContribute

You can contribute just opening new issues here or sending a pull request with tests.

Github https://github.com/dbuarque/repack-lambda

Connect