Day #1 with Cloud Workflows: your first step to “Hello World”


With more and more interconnected services, making sense of their interactions becomes critical. With Google Cloud Workflows, developers can orchestrate and automate such complex systems by creating serverless workflows. 


In this series of articles, we will learn together how to use Cloud Workflows, and get to know all its features, with short and easy to read tutorials. For our first day, we’ll discover and use the Workflows UI in the cloud console. We will create a simple “hello world” workflow, consisting of a simple step. Going further, in the coming days, we’ll learn more about advanced features. But first things first!




In the Google Cloud console UI, you can locate Workflows in the Tools section of the hamburger menu:



You can pin this menu item, to have it stick at the top of the list.


The first time you are accessing this page, you’ll be greeted with the following screen, which will ask you to enable the Workflows API. So just click on “ENABLE”:



Once the API is enabled, you’ll be in the Workflows home screen:


Click on the “CREATE” button to create your first workflow definition:


Find a name for your workflow (it should start with a letter). You can provide an optional description. Currently, only “us-central1” is available for the beta of Cloud Workflows, but more regions will be available later on. 


Notice that we have to select a service account that Workflows will use to call other Google Cloud APIs, however here, there’s a warning telling us that the project requires a service account. As I’ve created a brand new project, I didn’t have any service account created. If you had used, for example, Cloud Functions beforehand, a default service account would have been created. If you need to create a service account, you can create one in “IAM & Admin > Service Accounts”, then use this one.


My first workflow will be called “w01-first-workflow”:



Move on to the next section with the “NEXT” button. That’s where you will define your workflow:

This first workflow consists in one single step, called “sayHello”, and whose sole purpose is to return a hello world message:


- sayHello:
    return: Hello from Cloud Workflows!

As you can see, workflow definitions are written using the YAML configuration language.


Click “DEPLOY” to deploy the workflow. You will then see the details of your new workflow. In the “executions” tab, you can see past executions.


In the “logs” section, you can see the logging messages associated with your workflow creation, deployment and executions:
And in the “definitions” section, you can see the YAML description you just created:
Now click on the “EXECUTE” button. You will see the input section (we’ll learn about input arguments in an upcoming article), and the YAML definition. Click the other “EXECUTE” button:
You will see the result of your execution (“succeeded”, with other details about the execution), as well as both the input and the output, with our greeting message:
And here you are! You created your first workflow definition, and launched the first execution of this workflow!

In the coming days, we will have a closer look at the structure of workflow definitions (its steps), how to define input arguments, but also how to create an execution of a workflow from the command-line.


 

 
© 2012 Guillaume Laforge | The views and opinions expressed here are mine and don't reflect the ones from my employer.