[Nodejs] 4Steps Set up AWS Lambda with githiub and travisCI

[Nodejs] Set up AWS Lambda with githiub and travisCI

This is a Node.js boilerplate/startKit which configures continuous deployment process for AWS Lambda from Github using Travis CI. Process: github -> travisCI -> aws lambda

Challenges, there are few difficulties during the time I dig into this process, you must take time to read the document of both AWS and TravisCI:

  1. IAM Configuration, to understand how AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY work on Node.js and how it impact AWS’s services.
  2. TravisCI Life Cycle, need to read the doc of it, and make the process clean how a project is build, run, test and deploy.
  3. AWS Lambda Deployment, there are few ways on deploying a lambda function, like zip, serverless, codepipeline, aws cli or Nodejs SDK. Each of them has little different and requires different credential. (zip is the one I picked)

Step 1 — creating a lambda function

creating a lambda function, helloworld

Step 2 — create and set up deployment user

create user with policy lambda full access, getting the access_id and secret from IAM

and setup ENV variable

$ export AWS_ACCESS_KEY_ID="yourkey"
$ export AWS_SECRET_ACCESS_KEY="yoursecret"

Step 3 — local configuration

Step 3.1 — set up lambda name

set up lambda function name on

  • ./lambda/yourname
  • set your name here: ./lambda/yourname/package.json

Step 3.2 — set up lambda region

and setup region

Step 3.3 — set up TravisCI

and setup region

Step 4 — run

clone this project https://github.com/p-tool/nodejs-aws-lambda-travisci and run

$ npm run deploy
// or yarn deploy


Sample travisCI https://travis-ci.org/p-tool/nodejs-aws-lambda-travisci, which is connected to the sample Github Repo https://github.com/p-tool/nodejs-aws-lambda-travisci

read original article here