I have an AWS Lambda function that uses oauth2client
and SignedJwtAssertionCredentials
.
I have installed my requirements locally (at the root) of my Lambda function directory.
requirements.txt
boto3==1.2.5
gspread==0.3.0
oauth2client==1.5.2
pyOpenSSL==0.15.1
pycrypto==2.6.1
My lambda function looks like:
import boto3
import gspread
from oauth2client.client import SignedJwtAssertionCredentials
def lambda_handler(event, context):
dynamodb = boto3.resource('dynamodb')
scope = ['https://spreadsheets.google.com/feeds']
private_key = "!--some-private-key"
google_email = "some-email"
credentials = SignedJwtAssertionCredentials(google_email, private_key, scope)
gc = gspread.authorize(credentials)
However, when running this, I get the following stack trace:
{
"stackTrace": [
[
"/var/task/lambda_function.py",
20,
"lambda_handler",
"credentials = SignedJwtAssertionCredentials(google_email, private_key, scope)"
],
[
"/var/task/oauth2client/util.py",
140,
"positional_wrapper",
"return wrapped(*args, **kwargs)"
],
[
"/var/task/oauth2client/client.py",
1630,
"__init__",
"_RequireCryptoOrDie()"
],
[
"/var/task/oauth2client/client.py",
1581,
"_RequireCryptoOrDie",
"raise CryptoUnavailableError('No crypto library available')"
]
],
"errorType": "CryptoUnavailableError",
"errorMessage": "No crypto library available"
}
From everything I've read online, I am told that I need to install pyopenssl. However, I already have that installed and pycrypto.
Is there something I'm missing?
Looks like this is a bit old of a question, but if you are still looking for an answer:
This occurs because one or more of the dependencies for pyopenssl is a native package or has native bindings (cryptography is a dependency of pyopenssl and has a dependency on libssl) that is not compiled for the target platform.
Unfortunately the process varies for how to get compiled versions. The simplest way (which works only if its a different in the platforms, not missing .so libraries) is to:
This zip will then need to be expanded into your lambda zip before uploading. The result will be the required packages residing at the root of your zip file (not in site-packages or dist-packages folders)
For simple dependencies this works, if you require native libraries as well (such as for Numpy or Scipy) you will need to take more elaborate approaches such as the ones outlined here: http://thankcoder.com/questions/jns3d/using-moviepy-scipy-and-numpy-in-amazon-lambda
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.