This function that runs as a cron job using the serverless schedule event. For more information on schedule event check out the Serverless docs on schedule.
Schedule events use the rate or cron syntax.
cron(Minutes Hours Day-of-month Month Day-of-week Year)
All fields are required and time zone is UTC only.
Field | Values | Wildcards |
---|---|---|
Minutes | 0-59 | , - * / |
Hours | 0-23 | , - * / |
Day-of-month | 1-31 | , - * ? / L W |
Month | 1-12 or JAN-DEC | , - * / |
Day-of-week | 1-7 or SUN-SAT | , - * ? / L # |
Year | 1970-2199 | , - * / |
Read the AWS cron expression syntax docs for more info on how to setup cron
The function is scheduled to execute at 21:00 SUN-THU/UTC time (This is every weekday morning in Melbourne)
Run nvm use
to get the correct version of node
- Install yarn
curl -o- -L https://yarnpkg.com/install.sh | bash
- Install serverless globally
npn install -g serverless
Run yarn
after
In order to deploy the function run:
yarn deploy:full
There is no additional step required. Your defined schedule becomes active right away after deployment.
To test function locally and view the results run:
yarn invoke
yarn upgrade-interactive
https://blog.shanelee.name/2017/07/28/how-to-save-costs-with-serverless-and-aws-lambda/