O'Reilly logo

AWS Lambda Quick Start Guide by Markus Klems

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required