plyzico
plyzico

Reputation: 23

AWS Lambda layer not working: Failed to import handler function "lambda_function.lambda_handler" due to exception: No module named

I try to use AWS Lambda layer with opcua-asyncio libary but I got on my greengrass client the following error message:

Failed to import handler function "lambda_function.lambda_handler" due to exception: No module named 'asyncua'

What I did:

mkdir layer
cd layer
mkdir python
cd python
pip3 install asyncua -t .
cd ..
zip -r layer.zip python*

Uploaded that file as layer, with compatible runtimes: python3.8 and use that layer with the following lambda_function.py

import json
import asyncua

def lambda_handler(event, context):
    # TODO implement
    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda!')
    }

When I use the Test function I get no error and the response:

Response
{
  "statusCode": 200,
  "body": "\"Hello from Lambda!\""
}

But the published version of that lambda function doesn't work... see the error code at the beginning. I also tried with other libaries like pandas and its the same error ;(

I also tried different folder structure for the layer.zip:

python/lib/python3.8/site-packages/{LibrariesGoHere}.

Can someone help?

Upvotes: 0

Views: 683

Answers (1)

plyzico
plyzico

Reputation: 23

I found the answer to my question:

are-lambda-layers-supported-for-lambdas-deployed-to-greengrass

AWS lambda layers are not supported with greengrass core :(

Upvotes: 2

Related Questions