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

Published
Length
3 min read

Luis Felipe Dias

All posts

You pair google compute engine and google pub/sub to move messages between virtual machines. Virtual machines run your code while the message queue passes data between tasks. This setup lets one machine send work to another without waiting for a reply. When traffic spikes, the message queue holds jobs until worker machines can run them. Teams use this pattern to process logs, resize images, and handle background tasks. How google compute engine and google pub/sub pass data and check roles Ea

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.

You pair google compute engine and google pub/sub to move messages between virtual machines. Virtual machines run your code while the message queue passes data between tasks.

This setup lets one machine send work to another without waiting for a reply. When traffic spikes, the message queue holds jobs until worker machines can run them. Teams use this pattern to process logs, resize images, and handle background tasks.

How google compute engine and google pub/sub pass data and check roles

Each virtual machine needs a clear identity before it can send or read messages. You attach a dedicated service account to the virtual machine when you create it. The machine fetches short-lived tokens from the local metadata server on its own.

Your app uses that token to talk to the message topic or subscription. You do not need to store static JSON key files on the disk. When the app sends a message, the cloud checks the role on that account.

A publisher role lets the virtual machine write new events to a specific topic. A subscriber role lets a worker machine pull messages and mark them as done. Data moves over the internal cloud network when you turn on private access. This keeps message traffic off the public internet and cuts down network delay.

Common failure modes and how to scope roles and networks

Many teams leave the default compute service account on every virtual machine they build. That default account often has broad editor permissions across the whole cloud project. If an attacker compromises one machine, they can read or delete every topic.

Another common mistake happens when engineers download service account keys for local testing. Those keys end up on shared disks or inside source code folders. Anyone with the key can publish fake events or drain real queues from anywhere.

End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Unlogged access during live debugging also creates big blind spots for security teams. When an engineer logs into a machine to inspect a broken queue, actions blend together. Audit logs show the machine identity instead of the person who ran the check.

You can fix these risks by giving each workload its own narrow service account. Bind the publisher or subscriber role at the single topic level, not the project. Turn off broad access scopes on your virtual machines so roles stay strict.

Use private network paths so machines reach the message service without public addresses. Set up dead-letter topics to catch bad messages that fail processing several times. Also watch the age of the oldest unacknowledged message to spot stuck workers early.

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 a virtual machine log in to the message queue?

Attach a custom service account to the virtual machine and use the metadata server. Never put static JSON key files on the disk of the machine.

Should I use pull or push delivery for worker machines?

Pull delivery works best for virtual machines that process heavy background jobs at scale. Your workers pull messages at their own pace without needing open inbound ports.

How do I stop one machine from reading every topic in a project?

Grant the subscriber role on the single subscription instead of the whole cloud project. Give each group of worker machines a separate service account with strict rules.

The query runs. The emails stay hidden.