简体   繁体   中英

Installing python package on AWS lambda

I have deployed my zipped project without psycopg2 package. I want to install this package on my lambda without re-uploading my fixed project (i haven't access to my project right now). How can i install this package on my lambda ? Is it possible to do it with pip ?

It's not possible to do with pip . You have to add the dependency to your zipped Lambda deployment file. You can't modify your Lambda deployment without uploading a new zipped deployment file.

It is not possible to use pip directly on the lambda . Rather I use a custom build script to create zip package [this can give you a brief idea - it can certainly be made much simpler]

rm -rf ~/devops/tempenv > /dev/null
virtualenv ~/devops/tempenv
source ~/devops/tempenv/bin/activate
pip install SlackClient
pip install PyYaml
deactivate
rm -rf temp > /dev/null
mkdir temp
rm aws-lambda.zip > /dev/null
cp -r ~/devops/tempenv/lib/python2.7/site-packages/* temp/
cp *.py temp
cd temp
zip -r aws-lambda.zip .
mv aws-lambda.zip ../
cd ..
rm -rf temp
rm -rf ~/devops/tempenv

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM