Invoke Local and Layers

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

  name: aws
  runtime: python3.7

    handler: handler.hello
      - 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

Does no one have any experience using using layers? I have ended up using AWS SAM for my application. It’s a very light wrapper around cloudformation and lambda and is easy to understand what it is doing. There were a couple small gotchas with it (building your own layers is not fully supported by the tool), but overall seems to work a lot nicer in the AWS ecosystem, and does support running layers locally right out of the box.

So you ditched serverless to go with AWS SAM?
11 Months later are you happy with your local development ecosystem? Would you recommend going with SAM over serverless?

Hi @ltomes,

11 months later and, no we are still not entirely happy with our serverless setup. To be honest we have not put that much time and effort behind it, but the main blocker for us is that all of these tools (serverless + aws sam) use cloudformation to manage the functions at the end of the day, which makes it very difficult for us to standup lambdas when all of our other infrastructure is defined in terraform scripts. To get around this right now we are using paramater store and secrets manager to pass values from terraform such as database names or kinesis stream names into our sam templates. It works, but it is very clunky and easy to mess up.

My latest thinking on the matter has been to just standup “blank” functions using terraform, with all the associated environment variables and lambda config/permissions in place and then use a CD tool to drop our code in place. Yeah we miss some of the nice things that we get from SAM, but at the end of the day it is just cloud formation, so we could easily still take advantage of the macros/templates that SAM has added to cloudformation by setting up a stack ourselves in terraform.

Hope that helps give you some more context on the matter.

Hey there! Having a similar issue here.
Trying to user chrome-aws-lambda layer to run a nodejs puppeteer function locally using docker:

# serverless invoke local --docker -f server --path lib/ace.json
Serverless: Deprecation warning: Resolution of lambda version hashes was improved with better algorithm, which will be used in next major release.
            Switch to it now by setting "provider.lambdaHashingVersion" to "20201221"
            More Info:
Serverless: Packaging service...
Serverless: Excluding development dependencies...
START RequestId: 48c647e8-b4de-118d-f1f6-1e1223bbcced Version: $LATEST
2021-04-08T20:43:40.289Z        48c647e8-b4de-118d-f1f6-1e1223bbcced    INFO    Error setting browser:  Error: Could not find browser revision 800071. Run "PUPPETEER_PRODUCT=firefox npm install" or "PUPPETEER_PRODUCT=firefox yarn install" to download a supported Firefox browser binary.
    at ChromeLauncher.launch (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/node/Launcher.js:86:23)
    at Puppeteer.launch (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Puppeteer.js:97:31)
    at PuppeteerExtra.launch (/var/task/node_modules/puppeteer-extra/dist/index.cjs.js:129:41)
END RequestId: 48c647e8-b4de-118d-f1f6-1e1223bbcced
REPORT RequestId: 48c647e8-b4de-118d-f1f6-1e1223bbcced  Init Duration: 361.59 ms        Duration: 54.86 ms      Billed Duration: 55 ms  Memory Size: 10240 MB   Max Memory Used: 73 MB

{"statusCode":400,"headers":{"x-powered-by":"Express","content-type":"application/json; charset=utf-8","content-length":"57","etag":"W/\"39-waPTIQOAeRulfrozS5mP5YjHz8M\""},"isBase64Encoded":false,"body":"{\"message\":\"Cannot read property 'newPage' of undefined\"}"}