I have a lambda function which was working fine but I wanted to import a package so I created a directory with index.js and installed my npm package.
Then created a zip of this folder and uploaded it using
aws lambda update-function-code --function-name smrtfac-test --zip-file fileb://lambda.zip
But now I am getting this error
index.handler is undefined or not exported
What could be the reason for it?
my index.js
and node_modules
are in the same directory.
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.
The third argument, callback , is a function that you can call in non-async handlers to send a response. The callback function takes two arguments: an Error and a response. When you call it, Lambda waits for the event loop to be empty and then returns the response or error to the invoker.
No, this isn't possible.
If you get an “index.handler is undefined” error on AWS lambda, it could be one of a couple things – essentially their code is doing “require (‘index’).handler (event, context, callback)” and erroring out: Your index.js script has incorrectly named exports
The index.js (which contains the handler function that iterates over the different modules) is never uploaded to the cloud. When executing the Lambda it can't find index.handler since it never got uploaded.
The name of the handler method in your function's handler configuration doesn't match your code. Each runtime defines a naming convention for handlers, such as filename. methodname. The handler is the method in your function's code that the runtime runs when your function is invoked.
The index file needs to be at the root to be able to be read and accessed by lambda. Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question.
This usually occurs when you zip up the directory, instead of zipping up the contents of the directory. When you open your zip file to browse the content, the index.js file should be in the root of the zip file, not in a folder.
You could also change the Handler section as below if your index.js is not directly under root folder as below
Consider using Lambda Layers for node modules: https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html#configuration-layers-path
This is because you are probably submitting the project inside a directory. You just zip all the files directly instead of zipping them into a directory. The index file needs to be at the root to be able to be read and accessed by lambda.
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