The Simplest Way to Make BigQuery and Google Pub/Sub Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use bigquery and google pub/sub to stream live event data into tables for fast queries. Google Pub/Sub takes in events from apps, and BigQuery stores them for reporting. This setup removes the need for slow batch jobs that run once a night. Your team can read fresh data within seconds after an app sends an event. Getting this pipeline right requires tight roles, clean schemas, and clear logs. How bigquery and google pub/sub move data and check roles An app sends a message to a topic in

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 bigquery and google pub/sub to stream live event data into tables for fast queries. Google Pub/Sub takes in events from apps, and BigQuery stores them for reporting.

This setup removes the need for slow batch jobs that run once a night. Your team can read fresh data within seconds after an app sends an event. Getting this pipeline right requires tight roles, clean schemas, and clear logs.

How bigquery and google pub/sub move data and check roles

An app sends a message to a topic in Google Pub/Sub. A subscription then pushes that message straight into a BigQuery table. You do not need to run extra worker servers for basic streaming loads.

When events need cleanup first, a processing job sits between the two tools. The job reads from the subscription, fixes the format, and writes to the table.

Google Cloud uses service accounts to check who can read and write data. The Pub/Sub service account needs a role that lets it write into your specific dataset. It should not have rights to read other tables or drop data.

Schema matching is a vital step in this flow. The topic can hold a schema rule that checks every message before it enters the queue. If a message matches the target table columns, BigQuery writes the row right away. If a message fails the check, Pub/Sub sends it to a dead-letter topic for review.

Common failure modes with shared keys and broad roles

Many teams fail by giving one shared service account to both developers and pipelines. When a person and an app share a key, audit logs lose their value. You cannot tell which engineer ran a manual query or changed a topic.

Static JSON keys create another big risk when engineers save them on laptops. If a key leaks, an attacker can read your event streams and warehouse tables. Teams should ban static keys and use short-lived tokens tied to real user identities.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Broad project roles also cause damage during daily work. An engineer who only needs to check dead-letter messages often gets full editor rights. That person can then read sensitive customer tables by mistake.

You can fix this by splitting roles by task and dataset. Give the streaming pipeline write access to the landing table only. Give engineers read access to clean views, and mask fields like emails or phone numbers. Masking rewrites matched fields in results so sensitive strings stay safe during ad-hoc checks.

Scoping network paths and logging every query

Good pipelines keep all traffic inside private cloud networks. You can set up private service paths so messages never cross the public internet. Service perimeter rules also block data from leaving your cloud boundary.

Logging is just as important as network walls. Automated pipelines run the same write step all day, which is easy to track. Human queries against BigQuery or manual pulls from Pub/Sub carry much higher risk.

Every manual query or message pull should map to a single person. Your logs need to show who ran the query, when it ran, and what rows returned. When you pair tight dataset roles with clear user logs, audits become fast and simple.

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

Do I need a processing job between Google Pub/Sub and BigQuery?

No, direct subscriptions can write messages straight into a BigQuery table without extra jobs. You only need a separate processing step if you must change or join data before storage.

How do we handle bad messages that do not match the table schema?

Set up a dead-letter topic on your subscription to catch any rejected messages. Your team can then inspect the bad payloads, fix the format, and send them again.

How can engineers debug live data without sharing service account keys?

Engineers should log in with their own identity provider accounts instead of using shared JSON keys. Masking rules can also rewrite emails, card numbers, and national IDs in query results.

The query runs. The emails stay hidden.