Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create AWS Lambda deployment package that uses Couchbase Python client

I'm trying to use AWS Lambda to transfer data from my S3 bucket to Couchbase server, and I'm writing in Python. So I need to import couchbase module in my Python script. Usually if there are external modules used in the script, I need to pip install those modules locally and zip the modules and script together, then upload to Lambda. But this doesn't work this time. The reason is the Python client of couchbase works with the c client of couchbase: libcouchbase. So I'm not clear what I should do. When I simply add in the c client package (with that said, I have 6 package folders in my deployment package, the first 5 are the ones installed when I run "pip install couchbase": couchbase, acouchbase, gcouchbase, txcouchbase, couchbase-2.1.0.dist-info; and the last one is the c client of Couchbase I installed: libcouchbase), lambda doesn't work and said:

"Unable to import module 'lambda_function': libcouchbase.so.2: cannot open shared object file: No such file or directory"

Any idea on how I can get the this work? With a lot of thanks.

like image 243
bananana Avatar asked Jun 25 '16 18:06

bananana


People also ask

How do I add dependencies to AWS Lambda?

The process of adding dependencies to an AWS Lambda consists of two steps. First, we have to install the dependencies in the source code directory. Later, we have to package our lambda function into a zip file that also contains all of the dependency files.


1 Answers

Following two things worked for me:

  • Manually copy /usr/lib64/libcouchbase.so.2 into ur project folder and zip it with your code before uploading to AWS Lambda.
  • Use Python 2.7 as runtime on the AWS Lambda console to connect to couchbase.

Thanks !

like image 189
Onkaar Singh Avatar answered Nov 03 '22 22:11

Onkaar Singh