The Simplest Way to Make BigQuery and Google Compute Engine Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams pair bigquery and google compute engine to run apps that query huge tables. Virtual machines process app logic while the data warehouse runs heavy queries fast. This setup keeps heavy math off your app servers. Your servers stay small and cheap while the data engine does the hard work. Many teams struggle when they wire these two tools together for the first time. Bad role setups and shared keys often create big security holes. How bigquery and google compute engine share roles and data

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 google compute engine to run apps that query huge tables. Virtual machines process app logic while the data warehouse runs heavy queries fast.

This setup keeps heavy math off your app servers. Your servers stay small and cheap while the data engine does the hard work. Many teams struggle when they wire these two tools together for the first time. Bad role setups and shared keys often create big security holes.

How bigquery and google compute engine share roles and data

A virtual machine needs a clear identity to talk to your data tables. Google Cloud gives each virtual machine its own service account by default. When an app runs on that machine, it asks the local metadata server for a token. The app then sends that token with every query request to the data API.

The data service checks if that service account has the right role to run jobs. It also checks if the account can read the target dataset and table. If both checks pass, the engine runs the query and sends back the rows. Data moves over Google internal networks when both tools sit in the same cloud setup.

Human users complicate this flow when they log into virtual machines to debug issues. If an engineer logs into a server, they take on the identity of that machine. Every query they run from that shell looks like it came from the machine itself. Audit logs show the server account name instead of the real person who ran the query.

Common failure modes and how to scope roles

The biggest mistake teams make is keeping the default compute service account on their servers. That default account often has broad editor rights across the whole cloud project. Any person or script on that machine can read or delete any table in the project. A single bug in your web app could expose all your customer data.

Static key files on virtual machine disks cause another major risk for your team. Engineers sometimes download JSON keys to test queries from a server shell. Those files sit on the disk forever and never expire on their own. Attackers who break into the server can steal that file and use it from anywhere.

BigQuery IAM + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

You can fix the machine side by making a custom service account for each app. Give that account the ability to run jobs and read only the one dataset it needs. Never grant project-wide read or write roles to a virtual machine service account. Delete any JSON key files sitting on server disks and rely on attached accounts instead.

You also need a better way to handle human engineers who run live queries. Do not let engineers log into compute instances just to query data tables. Separate your app runtime permissions from the permissions your team uses for support tasks. When people query tables directly, make sure every query ties back to their own email. You should also mask sensitive fields like emails, phone numbers, card numbers, and national IDs. Masking rewrites matched fields in results so support tasks stay safe.

Network paths and cost controls between your servers and tables

Good role design is only half of the puzzle for this tool pair. You also need to control the network path between your virtual machines and the data API. Virtual machines without public IP addresses cannot reach cloud APIs unless you turn on private access. Turning on private Google access on the subnet lets internal machines reach the data warehouse safely.

Cost spikes happen fast when an app or engineer runs a bad query in a loop. A virtual machine can fire hundreds of full table scans in just a few minutes. Set up custom quotas on the project or user level to cap daily query bytes. This simple rule stops a broken script on a server from draining your cloud budget.

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 put service account JSON keys on my virtual machines?

No, you should never store static JSON keys on your virtual machine disks. Attach a dedicated service account to the machine so it fetches short-lived tokens on its own.

Why can my virtual machine run queries if I only gave it table read access?

Reading data and running a query job require two separate permissions in Google Cloud. The machine needs both a data viewer role on the dataset and a job user role.

How do I stop engineers from sharing the virtual machine identity for ad-hoc queries?

Stop engineers from running data queries from inside shared virtual machine shells. Have them log in with their own work identity so logs show who ran each query.

The query runs. The emails stay hidden.