The Simplest Way to Make Cloud Run and Dataflow Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams pair cloud run and dataflow to handle web requests and run large data jobs. Cloud Run takes in fast events and starts Dataflow to process heavy files or streams. This setup keeps your web app fast while background workers crunch big data sets. Your front-end service stays small and cheap because it hands off heavy work right away. You only pay for compute time when requests arrive or when pipelines run. How cloud run and dataflow share roles and data A request hits your Cloud Run app t

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 cloud run and dataflow to handle web requests and run large data jobs. Cloud Run takes in fast events and starts Dataflow to process heavy files or streams.

This setup keeps your web app fast while background workers crunch big data sets. Your front-end service stays small and cheap because it hands off heavy work right away. You only pay for compute time when requests arrive or when pipelines run.

How cloud run and dataflow share roles and data

A request hits your Cloud Run app through an HTTP endpoint or a queue. The app checks the payload and decides if a batch or stream job should run. It then calls the Google Cloud API or drops a message into a topic.

To start a pipeline, the Cloud Run service account needs permission to launch jobs. It also needs permission to pass a worker service account to the new pipeline. Dataflow then spins up compute instances using that second worker role to read and write data.

Keeping these two identities separate is the best way to protect your cloud project. The web app role only needs rights to trigger templates and check job status. The pipeline worker role holds the rights to read storage buckets and write to tables.

Data moves between these two services through cloud storage buckets or message queues. Cloud Run never sends gigabytes of raw data straight into the pipeline start call. Instead, it writes the raw file to a bucket and passes that file path.

Common failure modes and how to scope permissions

Many teams make the mistake of using the default compute service account for everything. That default role often has broad project editor rights that create a huge risk. If an attacker tricks your web app, they gain full control over all data.

End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Shared accounts also make audit logs hard to read during an incident review. When ten apps and twenty pipelines share one identity, you cannot trace who read what. Giving each app and each pipeline its own role fixes this logging blind spot.

Network path mistakes also break production pipelines right when you launch them. Cloud Run might sit on a public network while Dataflow workers run inside a private subnet. If the worker subnet lacks private Google API routing, the pipeline will stall and fail.

You should disable public IP addresses on all your pipeline worker machines by default. Route all traffic between your web app, storage buckets, and workers over internal networks. Check that firewall rules allow workers to talk to each other on required ports.

Managing templates and human debug sessions

Hardcoding pipeline code inside your web container slows down your build and deploy loop. Use Flex Templates stored in cloud storage so Cloud Run only passes simple runtime parameters. This lets data engineers update pipeline logic without forcing web developers to redeploy their app.

When a pipeline fails, engineers often need to inspect staging buckets or query output tables. Granting permanent production database rights to every developer creates a big security gap. Teams need a safe way to check live data and mask sensitive fields like emails or card numbers.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Should Cloud Run trigger Dataflow directly or use Pub/Sub?

Use direct API calls when you run scheduled batch jobs from a saved template. Use Pub/Sub when your web app receives constant event streams that a running pipeline reads.

Why does my Cloud Run app fail to launch a Dataflow job?

The most common cause is a missing service account user role on the worker identity. The Cloud Run identity must have permission to act as the Dataflow worker service account.

How does Cloud Run know when a Dataflow batch job finishes?

Cloud Run should not wait or hold an open request while a long pipeline runs. Instead, let the pipeline write a completion event to a topic that triggers Cloud Run.

The query runs. The emails stay hidden.