I'm using GCP and serverless framework. And wish to create a scheduled function. For AWS lambdas i can add to the .yml:
functions:
crawl:
handler: crawl
events:
- schedule: rate(2 hours)
- schedule: cron(0 12 * * ? *)
Seems like no such option for GCP - correct me if i'm wrong. What is the simplest way to implement it in CGP?
Thanks for all the responses, this is the complete solution as i see it including yaml:
In serverless.yml:
functions:
oneMinute:
handler: oneMinuteHandler
events:
- event:
eventType: providers/cloud.pubsub/eventTypes/topic.publish
resource: 'projects/${self:provider.project, ""}/topics/one-minute-topic'
This will also create the topic when running serverless deploy
Now all that is left is to create a scheduler:
GCP -> Cloud Scheduler -> Create Job
Target: Pub/Sub
Topic: one-minute-topic