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"?

mate00
  • 2,727
  • 5
  • 26
  • 34
A_toaster
  • 1,196
  • 3
  • 22
  • 50
  • It does not exists, or may be in other directory. Also check https://stackoverflow.com/questions/35340921/aws-lambda-import-module-error-in-python – Atul Kumar May 16 '19 at 05:20

1 Answers1

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.

Arka Mukherjee
  • 2,083
  • 1
  • 13
  • 27
  • 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! – A_toaster May 16 '19 at 22:33