Reputation: 18790
I have a deployment package in the following structure:
my-project.zip
--- my-project.py
------ lambda_handler()
Then I define the handler path in configuration file
my-project.lambda_handler
Get the error:
'handler' missing on module
Can not understand that
Upvotes: 14
Views: 39247
Reputation: 468
While not specific to your provided example, this error can occur for another reason as well -- naming conflicts with standard library modules.
E.g. if I have the following package structure, and specify my handler as email.handler
, there will be a collision with the standard library email
package and a similar error will be raised: handler missing on module 'email'
my-project.zip
--- email.py
------ handler()
Upvotes: 0
Reputation: 2206
I had this issue and had to make sure I had a function called handler
in my file, e.g.:
# this just takes whatever is sent to the api gateway and sends it back
def handler(event, context):
try:
return response(event, 200)
except Exception as e:
return response('Error' + e.message, 400)
def response(message, status_code):
return message
Upvotes: 3
Reputation: 29150
There are some issues occurring this error.
The very first issue you’re gonna run into is if you name the file incorrectly, you get this error:
Unable to import module 'lambda_function': No module named lambda_function
If you name the function incorrectly you get this error:
Handler 'handler' missing on module 'lambda_function_file': 'module' object has no attribute 'handler'
On the dashboard, make sure the handler field is entered as function_filename.actual_function_name
and make sure they match up in your deployment package.
If only the messages were a bit more instructive that would have been a simpler step.
adrian_praja has solved the issue in aws forum. He answered the following
I belive your
index.js
should containexports.createThumbnailHandler = function(event, context) {}
Solution: Correctly specify the method call
This happens when the specification of the method called by node.js
is incorrect in Lambda's setting.
Please review the specification of the method to call.
In the case of the above error message, I attempted to call the handler method of index.js
, but the corresponding method could not be found.
The processing to call is set with "Handler" on the configuration tab.
Below is an example of setting to call the handler method of index.js
.
Upvotes: 15