Thanks to visit codestin.com
Credit goes to github.com

Skip to content

rkxtd/serverless-lambda-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

serverless-lambda-boilerplate

This project is powered by

Serverless

Project Status

CircleCI Coverage Status Dependency Status devDependency Status Github All Releases

The main goal of this Project is to have structured approach to develop, test, build, deploy and document serverless micro-services. Based on AWS Lambda, and serverless micro-framework.

What you will get:

  • Clear folder structure to put your code logically splitted to node.js modules.
  • Installed Karma tests runner with 100% code coverage, and corrals tests reporter.
  • Installed and configured APIDOC generator, with automated deployment to S3 Bucket and static webhosting.
  • Configured CI integration
  • Independent branches deployment
  • All kinds of badges
  • Automated API versioning based on NPM versioning (version of API correspond version in package.json)
  • Local development environment with possibility to run lambda functions and navigate thought generated APIDOC
  • Integration tests

Prerequisites

  1. You should have AWS account activated.
  2. Create 2 s3 buckets. One of those buckets should be a static website hosting.
    For more information refer to Setup s3 buckets section.
  3. Create AWS user.
    For more information refer to Serverless Documentation.
  4. Copy AWS user credentials into your ~/.bash_profile
    export AWS_ACCESS_KEY_ID=YOUR_AWS_ACCESS_KEY
    export AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_KEY

Installation

  1. Install node.js 4.x/6.x
  2. git clone [email protected]:xcomanche/serverless-lambda-boilerplate.git
  3. cd serverless-lambda-boilerplate
  4. npm install
  5. Edit src/config.js and specify your params.
    For more information refer to Setup config section.
  6. Edit circle.yml and specify your parameters.
    For more information refer to Setup circle.ci integration section.
  7. Edit src/serverless.yml and specify your params.
    For more information refer to Serverless Documentation
  8. To test demo version of the app hit npm run redeploy

NPM Commands

  1. clean - Clean build folder
  2. test - Run unit tests
  3. build:app - Build lambda functions from src/ folders into build/ folder
  4. deploy:app - Deploy lambda functions from build/ folder into AWS account
  5. build:doc - Build API Doc from src/ folder into doc/ folder
  6. deploy:doc - Deploy API Doc from doc/ folder into AWS S3 bucket
  7. redeploy - Runs sequentially npm run clean than build:app than deploy:app than build:doc than deploy:doc

Deployment

  1. npm run redeploy should do the trick and deploy your source code to dev environment
  2. In case you want to deploy into another env - than you need to specify correct env environment variable. BRANCH=develop npm run redeploy. Supported environments: dev, stage, prod and any other feature branches environements
  3. CircleCi always deploys your builds to it default branches environements

Branch to Environment corresponding table:

  • master - prod
  • release/* - stage
  • develop - dev
  • feature/number - featurenumber (eg feature/1 -> feature1)

Serverless commands

Follow the documentation on Serverless project

Setup config

TBD

Setup s3 buckets

TBD

Setup circle.ci integration

  1. Activate your project in circleci
  2. Receive your AWS credentials and put it into CircleCI Project Settings/AWS Permissions
  3. Receive your coveralls token and put it into CircleCI Project Settings/Environment Variables create COVERALLS_REPO_TOKEN var

Contribution

This is free and opensource product. Just take and use it as you want to :)