The Simplest Way to Make Spanner and Step Functions Work Like They Should
Teams use spanner and step functions to run workflows across cloud providers. Step Functions runs the logic while Spanner stores the global data. This setup lets teams build apps that span both AWS and Google Cloud. A state machine can trigger jobs, check status, and write results to a global database. Getting the two clouds to trust each other is the main challenge. Teams need a clear plan for identity, network paths, and query logs. How identity and data flow between spanner and step functi
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
Teams use spanner and step functions to run workflows across cloud providers. Step Functions runs the logic while Spanner stores the global data.
This setup lets teams build apps that span both AWS and Google Cloud. A state machine can trigger jobs, check status, and write results to a global database. Getting the two clouds to trust each other is the main challenge. Teams need a clear plan for identity, network paths, and query logs.
How identity and data flow between spanner and step functions
Step Functions runs inside AWS and uses AWS roles for identity. Spanner lives inside Google Cloud and checks Google IAM roles before any read or write. To link them, you set up workload identity federation between the two clouds. This setup lets an AWS role trade its token for a short Google token.
A serverless compute step inside the workflow makes the call to the database. That step assumes the AWS role, gets the Google token, and runs the query. Data flows back to the state machine as a small payload. The state machine then picks the next step based on that database result. Keep payloads small so the workflow does not hit state size limits. Store large records in the database and pass only record IDs between steps.
Common failure modes and how to scope roles
Many teams start by putting a static Google service account key in AWS. Static keys do not expire on their own and often leak in logs. If an attacker grabs that key, they can read or delete production data. Another common mistake is sharing one broad database role across all state machines. When ten workflows share one role, you cannot tell which workflow ran a bad query.
Unlogged queries also hurt teams during an outage or security audit. Cloud logs show that a state machine ran, but not the exact SQL statement. Engineers also need to check database state when a workflow fails in production. Giving engineers shared admin keys to check tables creates another huge security gap. If sensitive fields like emails, phone numbers, or card numbers sit in those tables, raw queries expose them.
Cloud Functions IAM + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
To fix the cloud link, give each workflow its own AWS role. Map each AWS role to a specific Google role with narrow database permissions. A workflow that only reads order status should never have write access. Use private network links or peering so database traffic stays off the public internet. Set timeouts and retry rules on every database step to handle brief network drops.
Handling manual checks and production data safely
Automated workflows still fail when bad data enters the system. An engineer must step in, read the failed state, and check the database row. Standard cloud consoles do not link human identity to every single query with field rules. Teams need a way to tie every human and machine action to an identity. Masking rules can also rewrite emails, card numbers, or national IDs in query results.
Govern statements and responses across databases and APIs
Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.
First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.
Frequently asked questions
How does Step Functions log in to Spanner without static keys?
Use workload identity federation between AWS and Google Cloud. An AWS compute step trades its native role token for a temporary Google access token.
How do we stop one workflow from changing tables owned by another team?
Create a separate IAM role for each workflow and use fine-grained access control. Grant each role read or write permissions only on the exact tables it needs.
What happens when a database call times out during a workflow run?
Step Functions catches the timeout error if you define retry and catch blocks. Make sure your database writes use idempotent keys so retries do not create duplicate rows.
Related guides
In this post