AWS Lambda: Getting Started with NodeJS

Setting up for a lambda environment can take a few steps, I’ve throw together a quick start guide for my personal reference to get up and running

npm install serverless -g
serverless create -t aws-nodejs

Navigate to https://console.aws.amazon.com/iam/home#/security_credential and create a new access key

serverless config credentials --provider aws --key {{key}} --secret {{secret key}}
serverless deploy

 

Code references

serverless.yml

service: lambda-test

provider:
  name: aws
  runtime: nodejs6.10

functions:
  hello:
    handler: handler.hello
    events:
      - http:
          path: users/create
          method: get

handler.js

'use strict';

module.exports.hello = (event, context, callback) => {
  const response = {
    statusCode: 200,
    body: JSON.stringify({
      message: 'Go Serverless v1.0! Your function executed successfully!',
      input: event
    })
  };

  callback(null, response);
};

Jon

Innovative, entrepreneurial and positively unsatisfied mind that constantly pushes the tech boundaries to create new solutions and devices that change people’s lives. Throughout my career, I have had the opportunity of having a multi-disciplinary experience, which led me to wear the hats of: Architect, IoT Consultant (Internet of Things Consultant), Developer, Designer, Engineer, Server Admin, Consultant and Project Manager – to name a few. Based on this diversified background, I get projects done by following smart ideas and well-planned goals. In a world which is getting more unconventional by the day, I use unconventional ways, and a very healthy dose of integrity, to create devices and solutions that help companies go from a steady present to a dynamic future.

You may also like...