serverless-python-requirements
serverless-python-requirements copied to clipboard
Layer: true not compatible with individually packaging & module separation
Bug Report
Description
-
What did you do? Tried to deploy several functions in different modules.
-
What happened?
-
What should've happened? Package each function individually, creating a layer with each function's requirements.
-
What's the content of your
serverless.yml
file?
service: name
provider:
name: aws
runtime: python3.8
profile: default
region: us-west-2
package:
individually: true
exclude:
- "**/*"
custom:
pythonRequirements:
useDownloadCache: true
useStaticCache: true
dockerizePip: non-linux
noDeploy: []
slim: true
strip: false
layer: true
functions:
Function1:
handler: index.handler
module: functions/function1
memorySize: 128
timeout: 2
Function2:
handler: index.handler
module: functions/function2
memorySize: 128
timeout: 2
Function3:
handler: index.handler
module: functions/function3
memorySize: 128
timeout: 2
Function4:
handler: index.handler
module: functions/function4
memorySize: 128
timeout: 2
plugins:
- serverless-python-requirements
- serverless-step-functions
- What's the output you get when you use the
SLS_DEBUG=*
environment variable (e.g.SLS_DEBUG=* serverless deploy
)
...
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Packaging Python Requirements Lambda Layer...
Error --------------------------------------------------
Error: ENOENT: no such file or directory, scandir '.serverless/requirements'
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information ---------------------------
Operating System: darwin
Node Version: 13.7.0
Framework Version: 1.63.0
Plugin Version: 3.3.0
SDK Version: 2.3.0
Components Core Version: 1.1.2
Components CLI Version: 1.4.0
Similar or dependent issues: #373, #408, #328
One workaround for this is to create 2 separate service definitions. One service that references an empty_requirements.txt file so it just copies the code in place using the package individually setting, and another service that references the real requirements.txt but is a layer only without a function definition. This article has an example layer-only file: https://medium.com/better-programming/intro-to-lambda-layers-in-python-95e092198c97
Any updates or alternative solutions regarding this issue?