Day #9 with Cloud Workflows: deploying and executing workflows from the command-line
So far, in this series on Cloud Workflows, we’ve only used the Google Cloud Console UI to manage our workflow definitions, and their executions. But it’s also possible to deploy new definitions and update existing ones from the command-line, using the GCloud SDK. Let’s see how to do that!
If you don’t already have an existing service account, you should create one following these instructions. I’m going to use the workflow-sa service account I created for the purpose of this demonstration.
Our workflow definition is a simple “hello world” like the one we created for day #1 of our exploration of Google Cloud Workflows:
To deploy this workflow definition, we’ll launch the following gcloud command, specifying the name of our workflow, passing the local source definition, and the service account:
You can also add labels with the --labels flag, and a description with the --description flag, just like in the Google Cloud Console UI.
If you want to update the workflow definition, this is also the same command to invoke, passing the new version of your definition file.
Time to create an execution of our workflow!
You will see an output similar to this:
Our workflow being very simple, it executed and completed right away, hence why you see the result string (our Hello from gcloud! message), as well as the state as SUCCEEDED. However, workflows often take longer to execute, consisting of many steps. If the workflow hasn’t yet completed, you’ll see its status as ACTIVE instead, or potentially FAILED if something went wrong.
When the workflow takes a long time to complete, you can check the status of the last execution from your shell session with:
If you want to know about the ongoing workflow executions:
It’ll give you a list of operation IDs for those ongoing executions. You can then inspect a particular one with:
There are other operations on executions, to wait for an execution to finish, or even cancel an ongoing, unfinished execution.
You can learn more about workflow execution in the documentation. And in some upcoming episodes, we’ll also have a look at how to create workflow executions from client libraries, and from the Cloud Workflows REST API.