3

I am trying to upload a zip file to AWS lambda but keep getting the error "Unable to import module 'lambda_function': No module named 'lambda_function'"

I've started very basic by creating a zip file named "lambda_function.zip" with one file inside "lambda_function.py". At a later stage I will need to include packages in the zip file, but for now it's a very simple function named lambda_handler only using json.

Once uploaded this is the file structure and the error message received after testing: code and error message screenshot

If I move lamda_function.py into the root folder "RWS-POC" then it works, but later on when I need to upload a larger zip file this won't be an option as editing via the interface is disabled.

I can also confirm that the handler is set to lambda_function.lambda_handler and the python file is named "lambda_function" and the function named "lambda_handler" lambda_function.lambda_handler settings screenshot

I'm sure I'm doing something very basic wrong, so any help would be very much appreciated.

Thanks!

0

1 Answer 1

2

Your lambda_function.py is inside folder called lambda_function. Just move your lambda_function to RWS-POC, or modify handler into:

lambda_function/lambda_function.lambda_handler
Sign up to request clarification or add additional context in comments.

1 Comment

just realised I was zipping the driectory rather than the contents of the directory! thanks !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.