Workflows Tip #20: Schedule a workflow execution

There are different ways to launch the execution of a workflow. In previous articles, we mentioned that you can use the gcloud command-line tool to create an execution, you can also use the various client libraries to invoke Workflows, or use the REST API . A workflow itself can also invoke other workflows!

But today, I’d like to tell you how to schedule the execution of a workflow. For that purpose, we’ll take advantage of Cloud Scheduler . The documentation is actually covering this topic in detail, so be sure to grab all the info there. However, I’ll go quickly through the steps, and tell you about a nice new feature in the cloud console to ease the scheduling of workflows!

First, you need to have both Workflows and Cloud Scheduler enabled:

gcloud services enable \ \

Cloud Scheduler will need a service account with workflows.invoker role, to be allowed to call Workflows:

gcloud iam service-accounts create workflows_caller_sa gcloud projects add-iam-policy-binding MY_PROJECT_ID \
— member \
— role roles/workflows.invoker

Now it’s time to create the cron job:

gcloud scheduler jobs create http every_5_minute_schedule \ 
— schedule= "*/5 * * * *" \
— uri= "" \
— message-body= "{\"argument\": \”DOUBLE_ESCAPED_JSON_STRING\"}" \
— time-zone= "America/New_York" \
— oauth-service-account-email= ""

Here, you can see that Scheduler will run every 5 minutes (using the cron notation), and that it’s going to call the Workflows REST API to create a new execution. You can also pass an argument for the workflow input.

The cool new feature I was eager to mention today was the direct integration of the scheduling as part of the Workflows creation flow, in the cloud console.

Now, when you create a new workflow, you can select a trigger:

Click on the “ADD NEW TRIGGER” button, and select “Scheduler”. A side panel on the right will show up, and you will be able to specify the schedule to create, directly integrated, instead of having to head over to the Cloud Scheduler product section:

And there, you can specify the various details of the schedule! It’s nice to see both products nicely integrated, to ease the flow of creating a scheduled workflow.

Originally published at



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Guillaume Laforge

Guillaume Laforge

Developer Advocate for Google Cloud Platform, Apache Groovy programming language project VP/Chair