Reputation: 3097
I'm trying to execute a Lambda function but I get the following error:
{
"errorMessage": "Bad handler 'AlertMetricSender': not enough values to unpack (expected 2, got 1)",
"errorType": "Runtime.MalformedHandlerName",
"stackTrace": []
}
My Lambda handler is specified in AlertMetricSender.py
:
from modules.ZabbixSender import ZabbixSender
def lambda_handler(event, context):
sender = ZabbixSender("10.10.10.10", 10051)
sender.add("Zabbix server", "lambda.test", 5.65)
sender.send()
Upvotes: 21
Views: 20710
Reputation: 5174
In my case, I'm using a custom-built docker image, and my handler is inside of a submodule.
This is what I had originally at the bottom of my Dockerfile
:
ENTRYPOINT [ "python", "-m", "awslambdaric" ]
CMD ["parent_module.main.lambda_handler"]
Instead of a python-style import path (<parent_module>.<sub_module>.<function_name>
), the CMD
format is actually <filepath>.<function_name>
. That means the parent module and child module need to be separated by a /
, not a .
. This is what worked for me:
ENTRYPOINT [ "python", "-m", "awslambdaric" ]
CMD ["parent_module/main.lambda_handler"]
Upvotes: 1
Reputation: 23592
This is normally caused by an incorrect value specified for the "Handler" setting for the Lambda function.
It is a reference to the method in your function code that processes events i.e. the entry point.
The value of the handler argument is comprised of the below, separated by a dot:
Make sure you have not missed the filename.
In this case, it looks like the handler should be set to AlertMetricSender.lambda_handler
.
Upvotes: 33