Closed ShaneC-C-Y closed 8 years ago
cryptography contains native code and that code is compiled for the architecture (and OS) of the current machine. The AWS lambda documentation currently appears to claim that zipping up your local directory will work, but that's patently untrue. In this case it appears you're running on a Mac, but Lambda needs things compiled as linux ELF shared objects (but also likely needs everything statically linked, etc). You can probably get help with doing that in some AWS Lambda specific forum/mailing list.
What is the solution for mac users ?
You'll need to build cryptography on an amazon linux AMI (likely with static linking). This is something none of the cryptography team have needed to do so we can't provide much guidance beyond the obvious here. If you do figure out how to do it we'd be happy to have you add a section to the docs for future users.
Anyone is able to solve this issue ? I am also facing same issue and using mac
Same issue here. I cannot package using a mac and upload the zip to AWS Lambda. You can package it on a Linux machine and it works, but has anyone come across a way around this using a Mac?
The cryptography manylinux1 wheels will work on Lambda. Additionally, you can build your own using a docker image. Unfortunately I don't have an example I can point to directly, but hopefully someone will write one soon.
https://medium.freecodecamp.org/escaping-lambda-function-hell-using-docker-40b187ec1e48
This will get rid of your ELF
problem, but will result in /var/task/cryptography/hazmat/bindings/_constant_time.so: undefined symbol: PyInt_FromLong
@refayathaque did you find a way around that error?
@Rohit-Rajan-Bose You just need to build using an AWS lambda docker. Github Project - docker-lambda
I'm using Serverless Framework with Serverless Python Requirements - it installs dependencies automatically: Serverless Framework Github Project - Serverless Python Requirements
My serverless.yml
custom:
pythonRequirements:
dockerizePip: true
https://romandc.com/zappa-django-guide/setup/#approach-2-docker-with-zappa-recommended
This worked for me if you are trying to deploy this as part of your Django dependencies with Zappa.
Solid example.
@refayathaque I came across the same problem. You might want to check your python version. If you built the project on a python 2.7 make sure that the target of your lambda is the same (python 2.7). It worked for me when I changed the target version
Using pip3 instead of pip to install cryptography worked for me.
Hi,
I have a problem in cryptography. I followed the steps in this tutorial (https://aws.amazon.com/blogs/compute/scheduling-ssh-jobs-using-aws-lambda/) I have installed
pycrypto
successfully. The code is like that:And this is the error message:
Thanks in advanced, hope someone can help me.