I use per-function requirements
โโโ serverless.yml
โโโ config
โ โโโ settings.py
โโโ function1
โ โโโ requirements.txt
โ โโโ index.py
โโโ function2
โโโ requirements.txt
โโโ index.py
serverless.yml is
package:
individually: true
functions:
func1:
handler: index.handler
module: function1
func2:
handler: index.handler
module: function2
package:
include:
- config/**
issuse is : the config/** wouldn't be include in func2. how can didi it
Hmm. I think it'd work if you do:
cd function1
ln -s ../config
cd ../function2
ln -s ../config
cd ..
sls deploy
I agree that's not optimal, but I think it should work. Any input @cgrimal, since you implemented the per-function requirements?
I managed to reproduce the issue indeed. That said, the handling of linking (now injecting) has been completely reworked since i implemented this feature and I don't see where the include directive is supposed to be handled. It might be a bug I'm afraid.
Even though @dschep's workaround should work, you can also use the vendor mechanism. With your exact folder structures, it works with this minimal serverless.yml file:
service: issue_168
provider:
name: aws
runtime: python3.6
package:
individually: true
include: # not working :'(
- config/**
functions:
func1:
handler: index.handler
module: function1
vendor: ./config
func2:
handler: index.handler
module: function2
vendor: ./config
plugins:
- serverless-python-requirements
You can run the sls package -v -f func1 command, and look into the function1.zip artefact created in the .serverless folder.
@dschep @cgrimal thanks, i will use vendor temporary.
Hi @cgrimal, I have a very similar structure to OP (the folder is called common instead of config) and I've tried to use vendor as you suggested but the folder does not get included.
airwitsX3:
handler: airwitsX3.handler
module: iot/processing/airwitsX3
vendor: ./common
events:
- stream:
type: kinesis
arn: "arn:aws:kinesis:${self:custom.region}:${self.custom.streamID}:stream/${self:custom.streamName}"
I have also tried @dschep's suggestion to put a symlink, this works but it's not possible to use exclude or slimPatterns anymore (I have a few tests in there).
I have tried to have a look in the source code but I'm not familiar with serverless plugin structure and cannot find the point where the vendor key is taken into account.
Is there a way to make either include or vendor work again?
Thanks!
Hi @antoniocaiazzo, I'm afraid I haven't been using (or working on) this project for too long now, and I don't think I can help you. You'll have better chances if you open a new issue (you may still reference this one).
I hope you'll find a solution.