The Simplest Way to Make Airflow and Cloud Run Work Like They Should
Teams use airflow and cloud run together to schedule and run containerized data tasks. Airflow manages the task order while Cloud Run scales the compute containers up and down. This pair keeps the scheduler light and moves heavy data work into isolated containers. Each task gets its own memory and CPU without blocking down the main scheduler. How airflow and cloud run share permissions and data The workflow starts when a scheduled task wakes up inside the scheduler. The scheduler picks the r
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 airflow and cloud run together to schedule and run containerized data tasks. Airflow manages the task order while Cloud Run scales the compute containers up and down.
This pair keeps the scheduler light and moves heavy data work into isolated containers. Each task gets its own memory and CPU without blocking down the main scheduler.
How airflow and cloud run share permissions and data
The workflow starts when a scheduled task wakes up inside the scheduler. The scheduler picks the right service account and asks Google Cloud for an identity token. It then sends an HTTPS request or starts a job on the container platform. The platform checks the token against IAM roles before it starts any container.
Once the container starts, it takes over the actual data work. The scheduler does not send big data files through the trigger request. Instead, it passes small job details like file paths, date ranges, or table names. The container reads raw data from cloud storage or a database and writes results back.
Meanwhile, the scheduler polls the job status or waits for the HTTP response. When the container finishes its work, it sends back a clean exit code. The scheduler reads this status, logs the result, and starts the next task.
Common failure modes and how to scope roles
Many teams give the scheduler one shared service account with broad project owner permissions. That single account can trigger every container and read every database table. If one workflow script has a bug, it can break unrelated production services. Shared accounts also make audit logs hard to read during a security review.
Another common risk comes from long-lived JSON keys stored inside the scheduler database. Engineers often paste static keys into task settings to fix permission errors fast. Those keys do not expire on their own and can leak in plain text logs. Database queries run by those tasks also go unlogged at the query level.
End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
To fix this, give each workflow its own narrow service account and IAM role. Grant the scheduler permission to invoke only the specific container service it needs. Inside the container, attach a separate runtime service account with limited database permissions. Use workload identity features instead of static JSON keys so tokens expire fast.
Network paths and data safety for container tasks
Public container URLs create another weak spot if IAM checks get turned off by mistake. Always set container services to require IAM login on every incoming request. Route traffic through private VPC paths so job requests stay off the public internet. This stops outside callers from guessing URLs and running costly compute jobs.
Data tasks often pull tables that hold sensitive customer details. When tasks query production databases, data masking rewrites matched fields in results. This protects emails, phone numbers, card numbers, and national IDs during batch runs. Teams should also log every database query alongside the task ID that started it.
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
Should I use Cloud Run services or jobs with Airflow?
Use services for fast tasks that respond to an HTTP call within a few minutes. Use jobs for longer batch scripts that process data and exit without serving web traffic.
How do I pass runtime values from a DAG to a container?
Pass small values like dates or bucket paths as environment variables or request body fields. Keep large datasets in cloud storage and pass only the file location to the container.
How can I stop tasks from using static service account keys?
Attach a Google Cloud service account directly to your scheduler worker nodes using workload identity. The worker can then ask the cloud metadata server for short-lived tokens on each run.
Related guides
In this post