nodejs in lambda code example

Example 1: js lambda

// Traditional Function
function (a, b){
  return a + b + 100;
}

// Arrow Function
(a, b) => a + b + 100;

// Traditional Function (no arguments)
let a = 4;
let b = 2;
function (){
  return a + b + 100;
}

// Arrow Function (no arguments)
let a = 4;
let b = 2;
() => a + b + 100;

Example 2: aws lambda function setup for node js

// first install serverless
$  npm install -g serverless
// create basic template
$  serverless create --template aws-nodejs --name candidate
// configure aws and genrate client id and client secret
serverless config credentials --provider aws --key <your_access_key_id> --secret <your_access_key_secret>
 // deploy
  serverless deploy

Tags:

Misc Example