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 ...

Get AWS Lambda Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.