I tried to deploy the package which had psycopg2 library in it to AWS lambda function i'm getting no module error, I have tried this from windows environment which I know is not compatible to aws environment. can anyone help me out on installing the psycopg2 and process of deploying into AWS lambda function. I'm new to AWS. TIA
2 Answers
AWS Lambda's are missing some postgres libraries, and the standard psycopg2 library will not work.
A solution to this is to use a different psycopg2 library from here - https://github.com/jkehler/awslambda-psycopg2 inside of your project, instructions on how to add it as a package within AWS Lambda are in the repo.
2 Comments
Build the layer package using the structure "python/lib/python3.9/site-packages".
After installing psycopg2-binary, rename the _psycopg.so file under the directory "psycopg2" ("_psycopg.cpython-39-x86_64-linux-gnu.so "is under the "psycopg" directory).
Put the layer into the Python lambda function and add it to the code.