This plugins compiles the function schedule event to a CloudFormation resource.
Compile Scheduled Events
hooks into the deploy:compileEvents
lifecycle.
It loops over all functions which are defined in serverless.yml
. For each function that has a schedule event defined,
a CloudWatch schedule event rule will be created.
You have two options to define the schedule event:
The first one is to use a simple string which defines the rate the function will be executed.
The second option is to define the schedule event more granular (e.g. the rate or if it's enabled) with the help of key value pairs.
Take a look at the Event syntax examples below to see how you can setup a schedule event.
A corresponding lambda permission resource is create for the schedule event.
Those two resources are then merged into the compiled CloudFormation template.
This setup specifies that the greet
function should be run every 10 minutes.
# serverless.yml
functions:
greet:
handler: handler.hello
events:
- schedule: rate(10 minutes)
This configuration sets up a disabled schedule event for the report
function which will run every 2 minutes once
enabled.
# serverless.yml
functions:
report:
handler: handler.error
events:
- schedule:
rate: rate(2 minutes)
enabled: false