Quantcast
Viewing all articles
Browse latest Browse all 14040

AWS Lambda | Runtime import module error: cannot import name 'x509' from 'cryptography'

I am trying to deploy the following function in Python on AWS Lambda:

import jsonimport boto3import osfrom azure.storage.blob import BlobServiceClient, BlobClient, ContainerClientdef lambda_handler(event, context):    s3 = boto3.client("s3")    connect_str = os.getenv('CONNECT_STR')    blob_service_client = BlobServiceClient.from_connection_string(connect_str)    records = event["Records"]    print("Received records from s3 to update" + str(len(records)))    for record in records:        key = record["s3"]["object"]["key"]        bucket_name = record["s3"]["bucket"]["name"]        print("Processing object with key:" + str(key))        file = s3.get_object(Bucket=bucket_name, Key=key)        itr = file["Body"].iter_chunks()        azure_container_client = blob_service_client.get_container_client(container=bucket_name)        azure_container_client.upload_blob(name=key, data=itr)        print("Object " + key +" transferred to azure successfully")

I download all the dependency by the following code on the terminal (Windows Power Shell):pip3 install target='Target Directory' azure-storage-blob

Then, I zipped the target directory includinglambda_function.py, then deployed to the AWS Lambda.

However, I received the following error:

{"errorMessage": "Unable to import module 'lambda_function': cannot import name 'x509' from 'cryptography.hazmat.bindings._rust' (unknown location)","errorType": "Runtime.ImportModuleError","requestId": "ca956e23-0d79-4897-8cfd-a0d74bca0098","stackTrace": []}

The Runtime: Python 3.9The Architecture: x86_64

I can successfully run from cryptography.hazmat.bindings._rust import x509 without any problem on my local computer.

What could be the problem? How can I solve it?

Thanks.


Viewing all articles
Browse latest Browse all 14040

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>