Invoke Local and Layers

#1

I have a very basic python project with a single layer. When running serverless invoke local --function hello or serverless invoke local --docker --function hello I get ModuleNotFoundError: No module named 'scipy'. Does serverless support layers with invoke local? I have seen some evidence that it does not, but there is no active github issue and all I have seen is

and this claims to have implemented it using docker in v1.39.0 (I am on v1.40.0)

My serverless.yml looks like

service: my-service

provider:
  name: aws
  runtime: python3.7

functions:
  hello:
    handler: handler.hello
    layers:
      - arn:aws:lambda:us-east-1:XXXXXXX:layer:AWSLambda-Python36-SciPy1x:2

And the handler looks like

import json
import scipy

def hello(event, context):
    body = {
        "message": "Go Serverless v1.0! Your function executed successfully!",
        "input": event
    }

    response = {
        "statusCode": 200,
        "body": json.dumps(body)
    }

    return response

    # Use this code if you don't use the http event with the LAMBDA-PROXY
    # integration
    """
    return {
        "message": "Go Serverless v1.0! Your function executed successfully!",
        "event": event
    }
    """
0 Likes