Skip to Main Content
AWS Lambda Quick Start Guide
book

AWS Lambda Quick Start Guide

by Markus Klems
June 2018
Intermediate to advanced content levelIntermediate to advanced
184 pages
3h 28m
English
Packt Publishing
Content preview from AWS Lambda Quick Start Guide

Programming a Lambda function with Node.js

Now, let's learn a little bit more about programming Lambda functions with Node.js. We are going to take a closer look at the function handler, and in particular its arguments, that is:

  • Event objects
  • Context objects
  • Callback objects

Open the handler.js file and delete the code that's in the function body. One way to learn about the event and context object would be to log them out on the console:

'use strict';module.exports.hello = (event, context, callback) => {    console.log('event is', event);};

Let's see what this gives us.

I am invoking the function locally to see what the output is with the function name set as hello:

sls invoke local -f helloevent is

Ok, my event, apparently, is null. Let's ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering AWS Lambda

Mastering AWS Lambda

Yohan Wadia, Udita Gupta

Publisher Resources

ISBN: 9781789340198Supplemental Content