The Simplest Way to Make BigQuery and Cloud Run Work Like They Should
Using bigquery and cloud run lets your web apps query huge datasets on demand. The container service runs your code while the warehouse handles all data storage and math. Teams use this pair to build fast APIs, reports, and data pipelines. Neither tool needs you to patch servers or manage cluster size. How bigquery and cloud run pass identities and data Each container revision runs as a dedicated cloud service account. That identity holds the permissions needed to run jobs and read specific
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.
Using bigquery and cloud run lets your web apps query huge datasets on demand. The container service runs your code while the warehouse handles all data storage and math.
Teams use this pair to build fast APIs, reports, and data pipelines. Neither tool needs you to patch servers or manage cluster size.
How bigquery and cloud run pass identities and data
Each container revision runs as a dedicated cloud service account. That identity holds the permissions needed to run jobs and read specific tables.
When a request hits your app, the container fetches a short-lived token from local metadata. It sends your SQL query to the warehouse API over the internal cloud network.
The warehouse checks the service role before it scans any rows or columns. It must check two separate rights for every single request. First, the role needs the right to start a compute job in the project. Second, the role needs permission to read the target dataset or table.
Results stream back to the container so your code can format the response. The container then scales down to zero when traffic stops.
Common failure modes with shared accounts and broad roles
Many teams leave the default compute service account on every single container. That default role often has project editor rights across the whole cloud account. If one web app gets compromised, an attacker can read or delete every dataset.
Shared accounts also ruin your audit logs during an incident. You can see that the container account ran an expensive query. You cannot tell which user or which team triggered that run.
BigQuery IAM + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Static JSON keys create another big risk when engineers test container code on laptops. Developers download service account keys to run the app locally against production tables. Those long-lived files end up in source code, chat logs, or build servers.
Fix this by creating one dedicated service account for each container service. Grant that role access to only the single dataset it needs to read. Put sensitive tables with emails, phone numbers, or card numbers in separate restricted datasets. Apply column masking rules so the warehouse rewrites matched fields in results before sending data back.
Scoping network paths and query costs
Big queries can drive up cloud bills if a container loops by mistake. Set cost controls and byte limits at the project or user level. This stops a bad web request from scanning terabytes of raw data.
You should also lock down the network path between your compute and data. Use private cloud access and service perimeters to keep data inside your network boundary. This stops an attacker from using stolen tokens from outside your cloud network.
For human engineers who debug data issues, avoid giving them direct service account keys. Require people to log in with their own work identity for every query.
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 my container use a JSON key file to query data?
No, never put static JSON key files inside a container image or secret store. Attach a dedicated service account to the container so the platform handles token rotation.
Why does my app get a permission error when it has dataset reader rights?
Reading data requires two different permissions in your cloud project. Your service account needs both data viewer rights on the dataset and job user rights to run queries.
How do we keep sensitive customer columns out of app logs?
Set up policy tags and data masking rules on columns with emails, phone numbers, or national IDs. The warehouse rewrites matched fields in results before the container receives the payload.
Related guides
In this post