Day #3 with Cloud Workflows: variable assignment and expressions

Now that we have multiple steps in our workflow definition, let’s see how we can pass data around, from a step to another.

In a step, you can assign values to variables. Those values can be ints, doubles, strings, or booleans (and also null). Use the assign keyword as follows:

- assignments:
- two: 2
- pi: 3.14
- message: "Hello"
- bool: True

Those variables are available in the whole scope of the workflow, and can be accessed in other steps. So let’s see how we can do something with those variables. Let’s add a second step to our workflow definition:

- twoPi:
return: ${"Twice pi is " + string(two * pi)}

We are using the ${} notation to create an expression. We’re multiplying two numbers, we’re converting them to a string, and we’re concatenating two strings together, to get our final value.

Note that not all operations are allowed on all types, so you might need to do some conversions with built-in conversion functions like the string() function in our example. There are all sorts of arithmetic operators or boolean logic operators.

For more information, you can read about variable assignments , data types, and expressions. Next time, we’ll also have a look at more complex data types.

Originally published at




A collection of technical articles and blogs published or curated by Google Cloud Developer Advocates. The views expressed are those of the authors and don't necessarily reflect those of Google.

Recommended from Medium

Introduction to MATLAB

OpenLeverage — Airdrop Guide! CONFIRMED

Docker Basic Commands — Part 1

PokeMine 2022 Iteration Map

An Obsolete Subject?

Find the Top 10 Files Larger Than 10GB on Linux

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

More from Medium

Applying a path pattern when filtering in Eventarc

Cloud Bigtable: Understanding Bigtables NoSQL 3-dimensional storage model using the Node.js client

How to connect your microservices— AWS vs GCP part 5

The Development of Serverless