AWS Lambda Python libssl C Library

Trying to create a deployment package for the Pusher service in Python on AWS lambda.

When I run simple code like this

from pusher import Pusher def pusherTest(context, event): mypusher = Pusher(app_id=u'***', key=u'***', secret=u'***') mypusher.trigger('testchannel', 'testevent', {u'some': u'data'}) 

I get a stack trace.

 libssl.so.1.0.0: cannot open shared object file: No such file or directory: ImportError Traceback (most recent call last): File "/var/task/Lambda.py", line 3, in pusherTest mypusher = Pusher(app_id=u'***', key=u'***', secret='***') File "/var/task/pusher/pusher.py", line 42, in __init__ from pusher.requests import RequestsBackend File "/var/task/pusher/requests.py", line 12, in <module> import urllib3.contrib.pyopenssl File "/var/task/urllib3/contrib/pyopenssl.py", line 54, in <module> import OpenSSL.SSL File "/var/task/OpenSSL/__init__.py", line 8, in <module> from OpenSSL import rand, crypto, SSL File "/var/task/OpenSSL/rand.py", line 12, in <module> from OpenSSL._util import ( File "/var/task/OpenSSL/_util.py", line 6, in <module> from cryptography.hazmat.bindings.openssl.binding import Binding File "/var/task/cryptography/hazmat/bindings/openssl/binding.py", line 15, in <module> from cryptography.hazmat.bindings._openssl import ffi, lib ImportError: libssl.so.1.0.0: cannot open shared object file: No such file or directory 

I believe libssl is a C library, and since I don't have access to the Lambda machine to install these dependencies, how can I do this?

+5
source share
3 answers

Are you building a deployment package on a distribution other than Amazon Linux ? Try creating a deployment package on Amazon Linux

Python Extension Modules in AWS Lambda

+2
source

I had the same problem, and I had the opportunity to truly understand what the hint was. The next error is a cleanup, tell us that the libssl.so library does not exist ...

 ImportError: libssl.so.1.0.0: cannot open shared object file: No such file or directory 

I would expect it to be ... After all, Amazon Linux is a Linux distribution, and libssl should be there. But I don’t know ... maybe it is not directly accessible from the lambda function.

To solve the problem, I added the library to the zip package

 cd /usr/lib64 zip -u /tmp/lambda.zip libssl.so.1.0.0 

I redistributed, and the error was different. Eureka!

Another library was skipped. Libcrypto I did the same task and now my lambda function works as expected

 cd /usr/lib64 zip -u /tmp/lambda.zip libcrypto.so.1.0.0 
+4
source

Therefore, for me, the fix was to move the library files to the root folder as follows:

These files were in PIL> .libs

enter image description here

0
source

Source: https://habr.com/ru/post/1246603/


All Articles