I am trying to upload a python lambda function via a zip file. I copied all of my python files into a directory called "lambda", installed all of the libraries directly into that directory, did chmod -R 755 . to make sure all of those files are executable, and then zipped the directory with zip -r ../analysis.zip .
The file that holds my lambda function is called "main.py" and the lambda function is called "handler", so by AWS Lambda convention, I set the file it should be looking for to main.handler in the AWS Lambda page. I check my cloudwatch logs for this lambda function and still get an error saying aws cannot find the main module and also cannot find some regex._regex module as well.
This is the official error:
[ERROR] Runtime.ImportModuleError: Unable to import module 'main': No module named 'regex._regex'
Does anyone know what can be the problem? I have deployed aws lambda functions before using the same process and this is the first time I am getting this issue.
Lambda operates on a Python function/method not at the file. So the function handler must point to a actual function/method not a file.
So within your main.py file, there must be a function e.g. test_function, and your handler has to be main.test_function. The name of the function in AWS is irrelevant to the function.
Hope that helps.
Why does AWS Lambda not able to find my main.py?