Use a for-in loop to iterate through a map

Uses a for-in loop to iterate through a map.

Explore further

For detailed documentation that includes this code sample, see the following:

Code sample

YAML

- assignStep:
    assign:
      - map:
          1: 10
          2: 20
          3: 30
      - sum: 0
- loopStep:
    for:
      value: key                        # key = 1, 2, 3
      in: ${keys(map)}                  # [1, 2, 3]
      steps:
        - sumStep:
            assign:
              - sum: ${sum + map[key]}
- returnStep:
    return: ${sum}                      # sum is 60

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.