1 Answer
- Newest
- Most votes
- Most comments
2
The structure you provided seems correct, but it's worth double-checking that lambda_function.py is indeed at the root of the ZIP archive and not inside another folder. The structure inside the ZIP should not have lambda_package as a top-level directory. If you open the ZIP file, you should immediately see lambda_function.py and the directories for your dependencies, like so:
lambda_function.py pyotp/ pyotp-2.9.0.dist-info/ python_dotenv-1.0.1.dist-info/ requests/ requests-2.31.0.dist-info/
Use the following command from the directory containing lambda_function.py and the dependency directories:
zip -r9 ../lambda_package.zip .
If this has answered your question or was helpful, accepting the answer would be greatly appreciated. Thank you!
Relevant content
- Accepted Answerasked 3 years ago
- AWS OFFICIALUpdated 9 months ago
- AWS OFFICIALUpdated 2 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 3 years ago
Thanks for the suggestion. I have a correct zip file with the structure you mentioned. Somehow my previous lambda session did not save the function I was testing, while I was on lunch break, so I had to re-create my lambda function again. This time, I did not get the same error (even with the same zip file). Since your suggestion is correct, I will take your suggestion as an answer.