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

Published
Length
3 min read

Luis Felipe Dias

All posts

You use Google Pub/Sub and Pulumi together to build event queues with code. Pulumi creates the topics and subscriptions, while Pub/Sub moves messages between your apps. This workflow turns manual cloud clicks into tracked code changes. Teams can review queue updates in pull requests before anything runs in production. Every topic, dead-letter queue, and role rule lives in one versioned repo. How Google Pub/Sub and Pulumi share identity and data Pulumi needs a Google Cloud identity to create

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 use Google Pub/Sub and Pulumi together to build event queues with code. Pulumi creates the topics and subscriptions, while Pub/Sub moves messages between your apps.

This workflow turns manual cloud clicks into tracked code changes. Teams can review queue updates in pull requests before anything runs in production. Every topic, dead-letter queue, and role rule lives in one versioned repo.

How Google Pub/Sub and Pulumi share identity and data

Pulumi needs a Google Cloud identity to create and update Pub/Sub resources. You give the deployment runner a dedicated service account with specific Pub/Sub roles. During a deployment run, Pulumi calls the Google Cloud API using this identity.

It checks the current state of your topics and subscriptions against your code. Then it sends API requests to add, change, or delete those resources. Once Pulumi finishes the setup, your apps take over the data flow.

Publisher apps send messages to the topics that Pulumi just built. Subscriber apps read those messages based on the delivery rules in your code. Pulumi also sets up the service accounts that your apps use to talk. This keeps both resource creation and message flow inside one clear model.

Common failure modes and how to scope roles

Many teams fail by giving Pulumi one shared service account with broad owner permissions. If a bad actor steals that key, they control the entire cloud project. Another common mistake is storing long-lived JSON keys on developer laptops or build servers. Engineers also often run manual updates from local machines without central logs.

When a topic breaks, nobody knows who changed the settings or why. To fix this, split your roles between the deployment tool and the apps. Give Pulumi only the exact permissions needed to manage Pub/Sub resources and roles.

Pulumi Policy as Code + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Use workload identity federation so your build server logs in without static keys. Next, create separate service accounts for each publisher and subscriber app. Scope each app role to a single topic or subscription, not the whole project. Lock down network paths so only approved private networks can send or read messages.

Managing state and schema drift across teams

As your team grows, multiple services will depend on the same message queues. If one developer changes a message format, downstream subscriber apps can crash right away. You can prevent this by managing Pub/Sub schemas inside your Pulumi code.

When someone proposes a schema change, the deployment check flags any broken rules early. You should also store your Pulumi state file in a locked cloud bucket. Enable state locking so two engineers cannot run conflicting updates at the exact same time.

Set up dead-letter topics in your code for every main subscription you build. This catches failed messages and stops bad data from blocking your main queue. Finally, tag every topic and subscription with the owner team name and cost center. Clear tags help you track spending and find the right team during an outage.

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

How should Pulumi log in to Google Cloud without static keys?

Use workload identity federation to link your build pipeline directly to Google Cloud. This gives your deployment runner short-lived access without storing any JSON key files.

What happens if someone changes a Pub/Sub topic in the cloud console?

Pulumi detects the manual change during the next preview or refresh run. It will overwrite the manual edit so the cloud matches your code again.

Should publishers and subscribers share the same Google Cloud service account?

No, you should create separate service accounts for sending and reading messages. Give publishers write access to one topic and subscribers read access to one subscription.

The query runs. The emails stay hidden.