The Simplest Way to Make GitLab CI and Google Pub/Sub Work Like They Should
You link gitlab ci and google pub/sub to send build events to cloud apps. This setup lets your code runs trigger tasks across your cloud projects right away. Teams use this pattern to keep build jobs fast and separate from background work. When a build finishes, the runner sends a small message to a cloud topic. Other services read that message and start their own tasks without holding up the pipeline. How gitlab ci and google pub/sub share permissions and data The link between these two too
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 link gitlab ci and google pub/sub to send build events to cloud apps. This setup lets your code runs trigger tasks across your cloud projects right away.
Teams use this pattern to keep build jobs fast and separate from background work. When a build finishes, the runner sends a small message to a cloud topic. Other services read that message and start their own tasks without holding up the pipeline.
How gitlab ci and google pub/sub share permissions and data
The link between these two tools starts with how your runner logs in. A GitLab job needs a valid cloud identity before it can send a message. Most modern teams use open identity standards to trade a job token for a cloud token. The runner presents its short job token to the cloud identity pool. The cloud pool checks the token rules, such as the project name and branch name. If the rules match, the cloud issues a short-lived token back to the runner.
Once the runner logs in, it sends a message to a specific topic. Cloud permissions control which topics the runner can see and use. You give the runner identity a narrow role that only allows publishing messages. The runner cannot read old messages, delete topics, or change cloud settings. Downstream apps hold their own roles to read from subscriptions tied to that topic. This clear split keeps your build runners from holding too much power in the cloud.
Common failure modes and how to scope roles and network paths
Many teams start by saving a static service account key in their project variables. This static key approach creates a big risk for your cloud projects. Anyone with maintainer access in the code tool can copy that long-lived key. If a key leaks, an attacker can send fake messages from anywhere on the internet. Shared service accounts also make it hard to see which job sent a bad message. Every pipeline run looks the same in your cloud logs.
Overbroad roles cause the next major set of problems for engineering teams. If a runner holds an editor role, a bad script can delete cloud data. You should scope each project role to one single topic per pipeline stage. Test branches should only send messages to test topics, never to production topics. You can enforce this boundary by checking branch claims during the token trade step.
GitLab CI Security + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Unlogged messages and wide network paths also hurt team safety during incidents. If you do not turn on cloud data logs, you cannot trace message origins. Turn on audit logs for your topics so every publish event records the caller identity. For tighter control, run your own private runners inside your cloud network. Private runners let you keep message traffic off the public internet using private cloud routes.
How to keep message schemas and runner jobs clean
Even with good roles, bad message data can break downstream apps in production. A small change in a pipeline script might send broken text to your topic. If the receiving app cannot parse the message, it will fail and retry forever. This retry loop wastes cloud compute and fills up your error logs fast.
You can stop bad data by setting up a schema check on your topic. The cloud topic checks every incoming message against a strict format before accepting it. If a runner sends a message with missing fields, the topic rejects it right away. The build job fails fast, and the developer sees the error in the job log. You should also keep sensitive data like emails or card numbers out of build messages. Send only safe build metadata like commit hashes, job IDs, and status codes.
Govern statements and responses across databases and APIs
Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.
First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.
Frequently asked questions
Should we use static service account keys in GitLab variables?
No, static keys never expire on their own and are easy to leak. Use federated identity tokens so every build job gets a short-lived cloud token instead.
How do we stop feature branches from publishing to production topics?
Check the branch attribute inside your cloud identity pool mapping rules. Only allow the main branch identity to take the role that publishes to production topics.
What is the minimum role a runner needs to send messages?
Give the runner identity only the publisher role on the single target topic. Do not grant project-wide roles or allow the runner to read from subscriptions.
Related guides
In this post