1

I'm trying to import the yara library into an AWS Lambda function but I am consistently given the following error:

module initialization error: /var/lang/lib/libyara.so: cannot open shared object file: No such file or directory

I have tried adding a layer containing both the requests library and the yara library, importing requests works but importing yara does not.

The lambda function I am working with is as follows. It is doing nothing but importing yara at this stage.

import yara

def lambda_handler(event, context):

    return {
        'statusCode': 200,
        'body': 'Hello from Lambda Layers!'
    }

I have also tried creating a virtual environment, installing the packages, creating the lambda function and uploading it to AWS as a lambda function which gives the same error.

You cannot create symlinks in AWS Lambda for /var/lang/lib/libyara.so because lambda's only permit the writing to /tmp.

Is there anybody that has got this working?

1 Answers1

0
  • Worth checking the way the zip file is created, Also check the uploaded zip if its in the correct format.
  • The lambda_hanlder should be at the base of the root of the zip.
  • User pip install -r requirements.txt -t . or pip install yara-python -t .
amittn
  • 2,249
  • 1
  • 12
  • 19