The Simplest Way to Make Couchbase and Google Pub/Sub Work Like They Should
Teams use couchbase and google pub/sub to stream document changes into event queues in real time. A connector worker reads database updates and sends messages to downstream apps for fast processing. This setup keeps operational data and event streams in sync across your cloud systems. When a user updates a profile, the database writes the change to disk right away. The connector sees that update and pushes an event to the message topic. Other services read the topic and run their own tasks with
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 couchbase and google pub/sub to stream document changes into event queues in real time. A connector worker reads database updates and sends messages to downstream apps for fast processing.
This setup keeps operational data and event streams in sync across your cloud systems. When a user updates a profile, the database writes the change to disk right away. The connector sees that update and pushes an event to the message topic. Other services read the topic and run their own tasks without hitting the main database. This design keeps read load low on the cluster while feeding many consumers at once.
How data and keys flow in couchbase and google pub/sub
Data moves between these two systems through a dedicated worker app or eventing function. In the database, a change stream tracks every new write, update, or delete action. The worker reads this stream from a specific bucket and scope using a database user role. That role needs read rights on the source collection and write rights for checkpoint state.
Once the worker grabs a document change, it formats the payload as a message. The worker then logs in to the cloud message bus using a service account identity. Cloud IAM checks if that identity has permission to publish to the target topic. If the check passes, the message lands in the topic and waits for subscribers.
Data can also flow the other way when your apps need to save events. A consumer app pulls messages from a subscription and writes JSON documents into the database. In both directions, the worker app holds the keys for both the database and the cloud project. Managing those keys well is the main task for platform teams running this pipeline.
Common failure modes and how to scope roles
Many teams start by giving the worker a single admin account for the whole database. They also attach a broad project editor role to the cloud service account. This approach works in a test lab, but it creates huge risks in production. If an attacker steals the worker keys, they can read or delete every bucket and topic.
Shared service accounts also make it hard to track who ran a bad query. When an engineer logs in with the worker key to fix a bug, audit logs lack names. You only see the shared bot account in the logs, not the human who ran the command. Unlogged queries can expose raw emails, phone numbers, or card numbers stored in user documents.
End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
To fix this, split machine accounts from human accounts across both tools. Give the connector worker a database role scoped only to the exact collection it reads. On the cloud side, grant the publish role only on the single topic it needs. Use workload identity where possible so you do not store static JSON key files on disk.
Securing network paths and developer debug sessions
Network paths between the database nodes and the cloud message service also need tight rules. Do not expose database ports to the public internet just so cloud workers can reach them. Set up private peering or a virtual private network between your database cluster and cloud project. Route all message traffic through private cloud API endpoints instead of public routes.
Even with clean machine pipelines, engineers still need to inspect broken messages and bad documents. When a message fails to parse, a developer must check the raw document in the bucket. Giving developers permanent database passwords or downloading message payloads to laptops breaks your security model. Instead, require engineers to log in with their own identity provider accounts for every debug session. Masking rules can also rewrite matched fields like national IDs or card numbers in query results. This lets the team fix pipeline bugs while keeping sensitive customer fields safe and logged.
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 do you prevent duplicate messages when streaming database changes?
Workers save checkpoints in a metadata collection and attach a document mutation token to each message. Downstream subscribers check this token ID to drop repeat deliveries during network retries.
Should engineers use the connector service account to debug failed events?
No, sharing machine credentials hides who ran a command and gives humans too much access. Engineers should log in with individual accounts that log every query and mask sensitive fields.
How can we limit what data leaves the database for the message topic?
Scope the worker database role to specific collections and filter out private fields before publishing. You can also apply field masking on human read sessions to protect emails and phone numbers.
Related guides
In this post