I'm streaming

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);
};

An inventive, entrepreneurial and positively unsatisfied mind that constantly pushes the tech boundaries to create new solutions and devices that change people’s lives.

Leave a Reply