Anatomy of a Lambda Function

What makes up a Lambda function?

Dashbird is a monitoring platform for monitoring modern cloud infrastructure by providing alerts, insights and data visualisation.

Start a Free Trial Learn more

Basic code example

The most simplest Lambda function consist of one handler function.

  exports.handler = async function(event, context) {
    console.log('Hello world!');

As Lambda is an event driven service, the execution of the handler function is triggered by a user or system event.

Handler function

handler function will be executed each time a Lambda function is triggered. Handler takes two required arguments: an event object and a context object and an optional callback object.

Event and context

Event object is the first argument of the handler function and contains information about the event, for example an API request event holds the HTTP request object.

Context object contains information about the invocation, function configuration and execution environment.

Execution order

Lambda functions can be divided into two parts: code inside the handler function and the code outside of it. Code outside the handler function only gets executed during the cold start, while the code inside the handler executes per each function call.


The code outside the handler is executed only during the cold start.

Cold starts

Warm starts

Operate Cloud Applications at Highest Quality

Save time spent on debugging applications.

Increase development velocity and quality.

Get actionable insights to your infrastructure.

Finish setup in 2 minutes!