[英]psycopg2 does not work with Serverless framework deployment on AWS Lambda
I am trying to make a lambda function connect to Redshift, and deploy the same via The Serverless Framework.我正在尝试使 lambda function 连接到 Redshift,并通过无服务器框架进行部署。
serverless.yml config: serverless.yml 配置:
pythonRequirements:
dockerizePip: non-linux
dockerFile: ./Dockerfile
Dockerfile: Dockerfile:
FROM lambci/lambda:build-python3.6
RUN yum install -y postgresql-devel postgresql-libs
requirements.txt要求.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: AWS Lambda 给出错误:
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.而且我可以确认它丢失了,但是当我使用本地 docker 图像进行相同测试时,该文件存在。 I'm still unsure on how
serverless
actually deploys the package我仍然不确定无服务器如何实际部署
serverless
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?我不想使用
psycopg2-binary
并且我仍然不确定aws-psycopg2
,关于如何让代码运行的任何建议?
You can try using this module instead of default one (Supports only Python3.x)您可以尝试使用此模块而不是默认模块(仅支持 Python3.x)
https://pypi.org/project/aws-psycopg2/ 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.虽然上述内容没有得到积极维护,并且最大版本为
psycopg2==2.8.4
,但它可以服务于您可能拥有的用例。
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.如果您需要对旧版 Z23EEEB4347BDD26BFC6B7EE9A3B7 的支持,您还可以尝试从https://github.com/jkehler/awslambda-psycopg2压缩和上传 package。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.