Search⌘ K
AI Features

The Lambda Programming Model

Learn how the AWS Lambda programming model works by examining the lambdaHandler function in Node.js, how it processes HTTP events, and the use of async-await patterns. Understand the event and context objects, response requirements for API Gateway, and differences in typed versus untyped language interfaces.

lambdaHandler

In the sample template, the combination of CodeUri , Handler , and Runtime means that the Lambda environment will try to execute the code using Node.js version 24 by calling the function called lambdaHandler inside app.mjs in the hello-world directory.

Next, you’ll have a look at that file and inspect it, so you can see how Lambda responds to HTTP requests. That file will look similar to the following code:

Node.js
let response;
exports.lambdaHandler = async(event, context) => {
try {
response = {
'statusCode': 200,
'body': JSON.stringify({
message: 'hello world',
})
}
} catch (err) {
console.log(err);
return err;
}
return response;
};

Note that SAM ...