/aws-api-lambda-boilerplate

Sample project that shows how AWS api lambda with dynamoDB in continuous delivery

Primary LanguageJavaScript

aws-api-lambda-boilerplate

This boilerplate is an example project to deploy full stack (AWS Lambda, AWS API Gateway) to AWS S3.

Getting Started

Directory structure

-package.json
-Gruntfile.js
-README.md
-tools/
  |__create-api.js
  |__create-identity.js
  |__create-lambdas.js
  |__swagger-to-lambda.js
  |__update-api.js
 -config/
  |__credentials.local.json
  |__default.json
  |__dev.json
  |__prod.json
  |__swagger.json
-dist/
  |__resources-users-get-by-uid.zip
  |__...
-src/
  |__resources/
  |____users/
  |______get/
  |________index.js
  |________package.json
  |________event.json
  |________node_modules    
  |______get-by-uid/
  |______put/
  |______post/

Install

Install aws cli

sudo pip install awscli

Configure aws credentials

aws configure

Enter ACCESS_KEY_ID, SECRET_ACCESS_KEY and REGION.

Clone the project from CodeCommit

git clone smse-ac

Install dependencies

npm install

Change parameters in config/default, config/dev, config/prod

Set aws credential in project

  • Copy credentials.local.json to credentials.json
  • Set ACCESS_KEY_ID and SECRET_ACCESS_KEY

Create stack

Install project localy, deploy lambdas and set API with swagger.json to AWS.

grunt install

Usage Grunt Commands

Run jshint

grunt

Create or update local source directory based on swagger.json

grunt swagger_to_lambda

Create lambdas, if does not exist on AWS

grunt create_lambdas

Create api from swagger.json file, if does not exist on AWS

grunt create_api

Create api from swagger.json file on AWS

grunt update_api

Install the full stack (lambdas, api, s3,...) to AWS

grunt install

Invoke lambda locally

grunt run

Options

target: String

Usage: grunt run --target=usersGet

Package all lambdas locally

grunt package

Options

target: String

Usage: grunt package --target=usersGet

Upload packages lambdas to AWS s3

grunt upload

Options

target: String

Usage: grunt upload --target=usersGet

Package, upload and update lambdas to AWS

grunt deploy

Options

target: String

Usage: grunt deploy --target=usersGet

Test lambda localy

grunt test

Options

target: String

Usage: grunt test --target=usersGet