'AWS Lambda package dependencies failing to load

I am trying to use an API sdk to interact with a some software through AWS Lambda. I have packaged the dependencies correctly by zipping the pip installed packages in the correct directly structure: /opt/python/lib/python3.9/site-packages/ and uploaded them as a layer. I am confident of this because I am able to successfully import requests, one of the sdk's dependencies in the zip file. The error I get, when trying to import the sdk or cryptography its self:

{
  "errorMessage": "Unable to import module 'lambda_function': /opt/python/lib/python3.9/site-packages/cryptography/hazmat/bindings/_rust.abi3.so: cannot open shared object file: No such file or directory",
  "errorType": "Runtime.ImportModuleError",
  "stackTrace": []
}

I have unzipped the zipped layer file and can see the _rust.abi3.so file present in the directory stated in the error. I am creating the zip file on an Ubuntu image spun up through Docker.

I have tried using different versions of Python (3.6,3.7). I have attempted creating the layer both manually and through the code here.

I am using x86_64 Architecture, Python 3.9, pip3



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source