Hi all,
is there any kind of an internal template system, which I can use to create templates and configure them when they get referenced in serverless.yml?
Something like
functions:
myfunction:
name: MyFunction
handler: myfunc.py
events:
- ${template:myEvent(name="Event_1", rate="cron(0 * * * * *)", input.repos="[repo1, repo2]")}
Somewhere else the template could be defined like:
templates:
myEvent:
name: <placeholder/default>
enabled: True
rate: <placeholder/default>
input:
service: git
repos:
- my_repo_placeholders
So the template contains fix and changeable data.
I know I can load variables via ${self:custom.var1}
, but this is somehow static and allows me to have the data somewhere else only.
My use case:
I have a single Lambda function, which calculates stuff for a given git repository.
This calculation is triggered by an event and the event sets the repo-location via input.
But I have 50 repos and therefore I need for each repo one unique event (each with different input data).
So I end up having 50 event definitions.
For the event, only the input-url/repo changes, everything else stays the same: desc, rate, enabled, other input.
Right now I have a huge event.yml file, which has 50 events defined, which all look very similar (except the repo url). So >99% of written data are duplicates.
Any ideas how to solve this in a smarter way?