Search⌘ K

The Lambda Programming Model

Explore the AWS Lambda programming model by understanding how Lambda functions handle asynchronous execution, process HTTP requests, and generate responses. Learn about the lambdaHandler function, event and context parameters, and how SAM templates deploy serverless applications.

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 12 by calling the function called lambdaHandler inside app.js 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 generates ...