Consider following code -
function index(event, context, callback) { //some code } exports.handler = index(); { "errorMessage": "Handler 'handler' missing on module 'index'" }
This is my function which is having business logic. My javascript file name is index.js
.
Whenever I test this code on aws lambda, It gives following log(failed)
.
This is a screenshot of the Amazon Lambda Upload Site:
When you call it, Lambda waits for the event loop to be empty and then returns the response or error to the invoker. The response object must be compatible with JSON. stringify . For asynchronous function handlers, you return a response, error, or promise to the runtime instead of using callback .
This function handler name reflects the function name ( lambda_handler ) and the file where the handler code is stored ( lambda_function.py ). To change the function handler name in the Lambda console, on the Runtime settings pane, choose Edit.
You can invoke Lambda functions directly using the Lambda console, a function URL HTTP(S) endpoint, the Lambda API, an AWS SDK, the AWS Command Line Interface (AWS CLI), and AWS toolkits.
Lambda manages the function's asynchronous event queue and attempts to retry on errors. If the function returns an error, Lambda attempts to run it two more times, with a one-minute wait between the first two attempts, and two minutes between the second and third attempts.
In export.handler
, you are not referencing the index
function, but the result of its execution. I guess you want to export the function itself.
let index = function index(event, context, callback) { //some code } exports.handler = index;
Or maybe directly
exports.handler = function index(event, context, callback) { //some code }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With