The Simplest Way to Make BigQuery and Step Functions Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams pair bigquery and step functions to run cloud data jobs across AWS and Google. Step Functions drives the workflow steps while BigQuery runs large SQL queries at scale. This setup lets engineers trigger analytics jobs right after AWS tasks finish. You can move data, run reports, and alert teams from one state machine. How bigquery and step functions pass identity and data These two tools live in different clouds, so they do not share a login system. Step Functions uses AWS roles, while

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 pair bigquery and step functions to run cloud data jobs across AWS and Google. Step Functions drives the workflow steps while BigQuery runs large SQL queries at scale.

This setup lets engineers trigger analytics jobs right after AWS tasks finish. You can move data, run reports, and alert teams from one state machine.

How bigquery and step functions pass identity and data

These two tools live in different clouds, so they do not share a login system. Step Functions uses AWS roles, while BigQuery checks Google Cloud service accounts.

The best way to link them is through cross-cloud identity federation. Your state machine calls a small compute task or makes a direct HTTPS API call. That task trades its AWS role token for a short Google Cloud token. No static JSON key files ever need to sit in your AWS storage.

Data flow needs the same care across cloud lines. Step Functions has a small payload limit for state data passed between steps. You should not pull thousands of BigQuery rows straight into the state machine output. Instead, have BigQuery write results to a cloud bucket and pass the file path.

Because queries take time, synchronous calls often time out in long workflows. A good state machine starts the BigQuery job and saves the job ID. Next, a wait loop checks the job status every few seconds until it finishes.

Common failure modes and how to scope roles

Many teams take a risky shortcut when they first link these two tools. They create a Google service account key and save it as a shared secret. Soon, every state machine in the company uses that same static key.

BigQuery IAM + Cloud Functions IAM: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

If that key leaks, an attacker gains broad read and write power over your warehouse. Shared service accounts also ruin your audit logs during an incident review. Every query in the BigQuery log shows the exact same bot name. You cannot tell which workflow or engineer ran a broken or costly query.

Broad permissions make this problem much worse for data security. A single workflow might only need to read one table in one dataset. Yet teams often give the shared role full editor rights across the whole project. If a query returns sensitive fields like emails or phone numbers, masking rewrites matched fields in results.

To fix this, give each state machine its own unique AWS role. Map each AWS role to a matching Google service account with narrow rights. Scope BigQuery permissions down to the exact dataset or table needed for that job. Add job labels to every query call so logs trace back to the state execution.

Handling network paths and human debugging

Automated workflows are only half of the daily story for data teams. Sooner or later, a nightly state machine will fail on a bad SQL query. An on-call engineer must step in, check the state input, and test the query.

Teams often grant engineers persistent warehouse roles just to fix these rare bugs. That leaves standing human rights open all year for a task that takes ten minutes. Keep network paths tight and separate human debugging from automated state machine roles.

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

Can Step Functions call the BigQuery API without a Lambda function?

Yes, Step Functions can call external HTTPS endpoints directly from a task state. Still, signing the Google token exchange often requires a small helper task first.

How do we stop BigQuery jobs if a Step Functions run is canceled?

Add a catch and cleanup path inside your state machine definition. When a step fails or stops, send a cancel request with the saved BigQuery job ID.

Why do our BigQuery results break the Step Functions state output?

Step Functions caps the size of JSON data passed between states in a workflow. Write large query outputs to cloud storage and pass only the summary metadata forward.

The query runs. The emails stay hidden.