A nice boilerplate for a new AWS Lambda function
A good start for an AWS Lambda function. If you combine this with the aws-lambda-autodeploy-lambda you will have a very fast deployment process. When you push code to Github.com it will only take a couple of minutes to run all your test, deploy you code to S3 and refresh the Lambda function. All automatic while you're drinking a fresh cup of newly brewed coffee.
Features:
- Boilerplate for AWS Lamda functions.
- Automated unit tests with NPM and Jest.
- Code coverage with Jest.
- Code style and hits with ESLint.
- CI integration with Travis.
- And last but not least; deployment with AWS CloudFormation
Getting started with development
$ git clone
$ npm install
$ cp ./bin/set-env-dist.sh ./bin/set-env.sh
$ . ./bin/set-env.sh
$ npm run test:watch
Run all tests
Lint all of the relevant code
Build a new release
Report coverage to Coveralls.io
Update changelog
Travis and Coveralls setup
To get auto coveralls reporting working you need to add your encrypted Coveralls token in .travis.yml.
This is how you do it:
$ travis encrypt COVERALLS_REPO_TOKEN=<super_secret coveralls token> --add env.global
Steps for preparing your repo:
- Connect your Github.com repo to your Travis CI account. https://travis-ci.org/
- Add
AWS_ACCESS_KEYandAWS_SECRET_KEYto your Travis CI environment. - Edit
.travis.ymlto match yourbucket,upload-dirandregion. - Copy
.coveralls-dist.ymlto.coveralls.ymland add you secret key.
Next time you push to your master brach Travis will run your tests and if all is green report coverage to Coveralls.
Isn't this great? :D
CloudFormation
# To create a new stack: $ bash ./bin/create-stack.sh # To update a current stack: $ bash ./bin/create-stack.sh -u
Howto check for vulnerabilities in modules
# Install Node Security Platform CLI $ npm install nsp --global # From inside your project directory $ nsp check
Howto upgrade modules
$ npm install -g npm-check-updates $ ncu -u $ npm install --save --no-optional