I am trying to make a lambda function connect to Redshift, and deploy the same via The Serverless Framework.
serverless.yml config:
pythonRequirements:
dockerizePip: non-linux
dockerFile: ./Dockerfile
Dockerfile:
FROM lambci/lambda:build-python3.6
RUN yum install -y postgresql-devel postgresql-libs
requirements.txt
psycopg2==2.8.5
requests==2.22.0
boto3==1.9.234
Deployment is done via:
sls deploy --function fn_name --force
AWS Lambda gives an error:
libpq.so.5: cannot open shared object file: No such file or directory
And I can confirm that it is missing, but when I test the same with local docker image, the file is present. I'm still unsure on how serverless
actually deploys the package
I do not want to use psycopg2-binary
and I'm still unsure about aws-psycopg2
, any suggestions on how to get the code to run?
You can try using this module instead of default one (Supports only Python3.x)
https://pypi.org/project/aws-psycopg2/
While the above is not actively maintained, and has the max version as psycopg2==2.8.4
, it could serve the use-case you might have.
You can also try zipping and uploading the package from here https://github.com/jkehler/awslambda-psycopg2 if you need support for older python versions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With