Articles → AWS → AWS Lambda Function Handler

AWS Lambda Function Handler






Purpose





Async Handlers




exports.handler = async (event) => {
    // TODO implement
    const response = {
        statusCode: 200,
        body: JSON.stringify('Hello from Lambda!'),
    };
    return response;
};




Picture showing the output of async handler in lambda function
Click to Enlarge


Non-Async Handlers




exports.handler = (event,context,callback) => {
    // TODO implement
    const response = {
        statusCode: 200,
        body: JSON.stringify('Hello from Lambda!'),
    };
    callback(null, response);
};




Picture showing the output of non-async handler in lambda function
Click to Enlarge


Arguments In The Handler Method




  1. Event object → This object contains the information about the invoker
  2. Context object → This object contains information about the invocation, function, and execution environment
  3. Callback → This argument is used to send a response from the non-async handlers



Posted By  -  Karan Gupta
 
Posted On  -  Tuesday, January 31, 2023

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250