The Simplest Way to Make BigQuery and Hashicorp Vault Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Pairing bigquery and hashicorp vault lets teams manage cloud database keys without hardcoding secrets. You configure HashiCorp Vault to issue short-lived Google Cloud credentials for each query run. Data teams run large analytical queries across petabytes of cloud tables every day. Security teams need strict rules over who can read or write those tables. Static JSON keys on laptops or build servers create huge security gaps. When both tools work together, apps request fresh credentials right wh

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.

Pairing bigquery and hashicorp vault lets teams manage cloud database keys without hardcoding secrets. You configure HashiCorp Vault to issue short-lived Google Cloud credentials for each query run.

Data teams run large analytical queries across petabytes of cloud tables every day. Security teams need strict rules over who can read or write those tables. Static JSON keys on laptops or build servers create huge security gaps. When both tools work together, apps request fresh credentials right when a job starts. The secret store talks to the Google Cloud API and creates a temporary token. When the timer runs out, the cloud platform revokes that token on its own.

How bigquery and hashicorp vault handle roles and tokens

The workflow starts when a user or app logs in to HashiCorp Vault. The secret engine checks the identity against its internal policy rules first. If the check passes, it calls Google Cloud to build a short-lived token. You can choose between OAuth tokens or temporary service account keys for this step. OAuth tokens work best because they expire fast and need less cleanup work.

Next, the app takes that fresh token and sends a query to BigQuery. Google Cloud checks the IAM roles bound to that temporary identity before running SQL. You can map specific datasets or tables to distinct roles in your secret engine. An analyst role might only read marketing tables while an ETL job writes data. Every step leaves a trail in both the secret log and cloud audit logs.

Common failure modes with shared accounts and broad permissions

Many teams still fall back on one shared service account for all data jobs. When fifty people share one identity, your cloud logs lose all user context. You see the service account ran a heavy query, not the actual person. Worse, teams often grant project-wide editor roles just to make broken pipelines run. One leaked token can then expose every table in the cloud project.

Long-lived JSON keys also pile up if rotation jobs fail during network drops. Google Cloud limits how many keys a single service account can hold at once. If old keys do not clear out, new jobs fail to start on time. To fix this, bind narrow dataset roles to separate roles in HashiCorp Vault. Keep token lifetimes under one hour so unused credentials die fast on their own.

HashiCorp Vault + BigQuery IAM: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Scoping data permissions and protecting sensitive columns

Good role design splits human users from automated batch pipelines right from the start. Batch jobs need steady schedules and strict write rules for specific staging tables. Human analysts run ad-hoc queries and often touch tables with private customer records. Even with short-lived tokens, a valid read role returns full rows to the screen.

Cloud column tags help restrict who can query sensitive fields like emails or card numbers. Still, managing hundreds of fine-grained cloud roles across two platforms takes constant upkeep. Teams also want to rewrite matched fields like phone numbers or national IDs in results. Pairing secret management with query-level controls keeps both credentials and raw table data safe.

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 we use service account keys or OAuth tokens for BigQuery jobs?

Use OAuth tokens whenever your client library supports them for database queries. They expire without extra API calls and avoid hitting cloud service account key limits.

Match the audit log timestamp in HashiCorp Vault with the Google Cloud job log. You can also attach custom job labels when the query starts to track users.

What happens to a running BigQuery job when the short-lived token expires?

BigQuery checks permissions when the query starts and lets active jobs finish running. Still, the client cannot start new queries or fetch more pages once the token expires.

The query runs. The emails stay hidden.