serverless-python-requirements icon indicating copy to clipboard operation
serverless-python-requirements copied to clipboard

Lambda cannot find handler file after adding Layers

Open mhihasan opened this issue 4 years ago • 1 comments

I am using flask. I would like to add layers to install the requirements using the serverless-python-requirements package by setting layer: true. My project structure is as follows:

root

  • src
    • api
      • app.py
  • requirements.txt
  • servereless.yml

Content of serverless.yml is:

service: example
 
provider:
  name: aws
  runtime: python3.7
 
plugins:
  - serverless-wsgi
  - serverless-python-requirements
 
functions:
  api:
    handler: wsgi_handler.handler
    package:
      include:
        - "./src/api/**"
    layers:
      - { Ref: PythonRequirementsLambdaLayer }
    events:
      - http: ANY /
      - http: ANY {proxy+}
 
custom:
   wsgi:
      app: "src/api/app.app"
      packRequirements: false
      pythonBin: python
  pythonRequirements:
      layer: true
       ....

As per the above configuration, I am getting this error: Lambda can't find the file wsgi_handler.py. Make sure that your handler upholds the format: file-name.method.

Any help is highly appreciated. Thanks in advance.

mhihasan avatar Jan 14 '21 15:01 mhihasan

did you try changing wsgi_handler.handler to app.handler or changing app.py to wsgi_handler.py

rileypriddle avatar Dec 09 '21 09:12 rileypriddle