The Simplest Way to Make BigQuery and Bitbucket Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams pair bigquery and bitbucket to run SQL changes from version control. Code pushes trigger automated pipeline jobs that update tables and views in the warehouse. This workflow keeps data models in sync with your code repo. Engineers review every schema change in a pull request before it runs in production. That stops manual edits in the cloud console and prevents broken dashboards. How bigquery and bitbucket share roles and data Your repo stores SQL scripts, table schemas, and pipeline s

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 bitbucket to run SQL changes from version control. Code pushes trigger automated pipeline jobs that update tables and views in the warehouse.

This workflow keeps data models in sync with your code repo. Engineers review every schema change in a pull request before it runs in production. That stops manual edits in the cloud console and prevents broken dashboards.

How bigquery and bitbucket share roles and data

Your repo stores SQL scripts, table schemas, and pipeline steps. When a developer merges code, the pipeline runner wakes up and reads those files. The runner then logs in to Google Cloud to run the queries.

Most teams use federated identity tokens instead of static key files. The pipeline runner sends a short token to Google Cloud to prove its identity. Google Cloud checks the token and grants a specific service account role.

Once logged in, the runner sends the SQL statements to the data warehouse. The warehouse runs the job, updates the target dataset, and returns a status log. The pipeline reads that status and marks the build as passed or failed.

Common risks with shared service accounts and wide permissions

A common mistake is putting a long-lived JSON key in repo variables. If a bad actor steals that key, they can read or delete production data. Static keys do not expire on their own, so the risk keeps the session active for months.

Another failure mode happens when all pipelines share one admin service account. A test branch job can wipe a production table by mistake. Cloud logs only show the shared account name, not the person who pushed the commit.

BigQuery IAM + 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 branch type its own scoped role. Pull request jobs should only read production schemas and write to staging datasets. Merge jobs on the main branch get permission to update production tables.

You should also mask sensitive fields when developers run checks on real data. Data masking rewrites matched fields like emails, phone numbers, card numbers, or national IDs in results. This keeps test logs clean while engineers verify their SQL logic.

Setting up safe network paths and query logs

Cloud pipeline runners use wide pools of public IP addresses by default. Opening your data warehouse to every public IP creates a wide attack surface. Instead, run your jobs on self-hosted runners inside your private cloud network.

Private runners let you keep data traffic inside your own network boundary. You can also tag every query job with the commit hash and author name. Those tags flow into your cloud audit logs so you can trace every change.

When a bad query spikes costs or locks a table, tags help you act fast. You can check the log, find the exact pull request, and roll it back. Clear rules and tight roles make automated data pipelines safe for the whole team.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

How should pipelines log in to Google Cloud without JSON keys?

Use OpenID Connect federation between your repo provider and Google Cloud. The pipeline trades a short job token for temporary cloud credentials at run time.

How do we stop test branches from changing production tables?

Create separate cloud service accounts for test branches and production branches. Map your main branch to the production role and limit other branches to staging datasets.

How can we track which commit ran an expensive query?

Pass the git commit ID and build number as job labels on every query. You can then read those labels in your cloud audit and billing logs.

The query runs. The emails stay hidden.