0

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?

plyzico
  • 13
  • 3
  • Are you testing this in AWS Lambda (where it works) and then deploying the Lambda function to AWS IoT Greengrass (where it doesn't work)? I don't use Greengrass much, but does it support layers? I don't see mention of layers in the [Greengrass docs](https://docs.aws.amazon.com/greengrass/v2/developerguide/run-lambda-functions.html). – jarmod Jan 27 '22 at 20:17

1 Answers1

1

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 :(

plyzico
  • 13
  • 3