lambda-pdftk-example icon indicating copy to clipboard operation
lambda-pdftk-example copied to clipboard

[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function'

Open stephenstilwell opened this issue 4 years ago • 0 comments

my project's files & directories: https://i.stack.imgur.com/ZahqK.png

I have a Lambda Function, and the code I have uploaded to the Lambda Function is a zipped folder of my /Archive directory.

When creating Lambda Layer, do I upload a zipped PDFtk binary as 1 layer? and the libgcj as a 2nd layer? Or do I upload both of them in 1 layer?

Do I upload my lambdazip.sh in a Lambda Layer?

From what I understand, many of the people who run into this "[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function':" have issues because of their Lambda Handler.

My Lambda handler is: lambda_function.lambda_handler so this doesn't appear to be my issue.

Another common problem I've noticed on StackOverflow, appears to be with how people are compressing & zipping the files they upload to the Lambda Function.

Do I need to move my lambda_function.py? Sometimes this CloudWatch error occurs because the lambda_function.py is not in the ROOT directory.

Does my survey directory need to move?

I think the folders & directories I have here may be causing my issue.

Do I need to zip the directories individually?

Can I resolve this error by Zipping the entire project?

For more information, I also have a Lambda Layer for PDF Toolkit, called pyPDFtk in the codebase. In that Lambda layer is a zipped /bin with binaries inside.

If there is anything I can alter/change within my code or AWS configuration, please let me know, and I can return new CloudWatch error logs for you.

If you prefer to answer on StackOverflow: https://stackoverflow.com/questions/69902669/error-runtime-importmoduleerror-unable-to-import-module-lambda-function-no-m

stephenstilwell avatar Nov 12 '21 17:11 stephenstilwell