Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
AWS Lambda Quick Start Guide

You're reading from   AWS Lambda Quick Start Guide Learn how to build and deploy serverless applications on AWS

Arrow left icon
Product type Paperback
Published in Jun 2018
Publisher Packt
ISBN-13 9781789340198
Length 184 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Markus Klems Markus Klems
Author Profile Icon Markus Klems
Markus Klems
Arrow right icon
View More author details
Toc

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 hello
event is

Ok, my event, apparently, is null. Let's see what the context is, as shown next:

module.exports.hello = (event, context, callback) =&gt...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image