1

I have an AWS lambda that takes images from an S3 and copies them to an Azure blob storage.

The start of my code looks like this:

    import json
    import boto3
    # from azure.storage.blob import BlockBlobService, PublicAccess
    from pymongo import MongoClient
    import bson
    from urllib.parse import unquote
    from datetime import datetime
    import pytz
    import logging

This code runs fine. When I uncomment the azure storage line to get:

    import json
    import boto3
    from azure.storage.blob import BlockBlobService, PublicAccess
    from pymongo import MongoClient
    import bson
    from urllib.parse import unquote
    from datetime import datetime
    import pytz
    import logging

I now get:

Response:
{
  "errorMessage": "Unable to import module 'lambda_function': libffi-d78936b1.so.6.0.4: cannot open shared object file: No such file or directory",
  "errorType": "Runtime.ImportModuleError"
}

Why does importing an azure library cause the entire lambda_handler to not work? I have successfully included all the other libraries in the AWS Lambda Layer, so it definitely exists. The entire Lambda runs fine when I comment out this line of code, so what's going on?

If there was an issue importing azure.storage.blob, wouldn't it say "Unable to import module azure.storage.blob"?

1

1 Answer 1

2

You get this error due to the library not present in your Lambda Layer. Kindly try reconfiguring your Layer, or alternatively try creating a Deployment Package. Kindly refer to this documentation to learn how to create a Deployment Package for a Lambda function.

As mentioned in the comment by Atul Kumar, you could also have a look at this StackOverflow Question.

Sign up to request clarification or add additional context in comments.

1 Comment

Yup, turned out to be a Layer issue. I was just confused as to why it said it couldn't find the entire lambd_handler rather than just the module that was missing!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.