The Simplest Way to Make GCP Secret Manager and GitLab CI Work Like They Should
Pairing gcp secret manager and gitlab ci lets build jobs fetch secrets without static keys. The pipeline trades a short job token for cloud access during each run. This setup keeps static keys out of your source code and runner settings. Teams store passwords in one place and pull them only when builds run. How gcp secret manager and gitlab ci share trust and data The two tools talk to each other through open identity standards. When a pipeline starts, the build server makes a short token fo
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.
Pairing gcp secret manager and gitlab ci lets build jobs fetch secrets without static keys. The pipeline trades a short job token for cloud access during each run.
This setup keeps static keys out of your source code and runner settings. Teams store passwords in one place and pull them only when builds run.
How gcp secret manager and gitlab ci share trust and data
The two tools talk to each other through open identity standards. When a pipeline starts, the build server makes a short token for that job.
This token holds facts like the project path, branch name, and user identity. The build runner sends this token to Google Cloud workload identity pools.
Google checks the token against trust rules that your cloud team set up. If the check passes, Google returns a temporary cloud token to the runner.
The runner uses that cloud token to ask the secret store for specific values. The secret store checks the role tied to that identity before sending data.
Once approved, the secret value flows into the build memory for that single step. When the job ends, the runner wipes the memory and the token expires.
No human has to copy or paste keys into project variables. Rotation happens in the cloud store without breaking your next pipeline run.
Common failure modes and how to scope roles and networks
Many teams start by sharing one broad cloud service account across all projects. That mistake lets any test branch read production keys if a rule slips.
GCP Secret Manager + GitLab CI Security: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Static JSON keys stored in runner variables create another big risk. Those keys do not expire on their own and often leak in build logs.
Unlogged secret reads also hurt teams during security reviews. If ten pipelines use one identity, you cannot tell which job pulled a key.
To fix this, bind cloud roles to specific branch claims in the job token. Let only main or release branches read production secrets from the cloud store.
Create separate service accounts for each app and stage in your cloud project. Grant secret read permissions on single secret items rather than the whole project.
Keep your build logs clean by masking sensitive outputs in the runner tool. Even with masking, never print secret values to standard output during test steps.
Lock down network paths between your runners and your cloud resources as well. Private runners inside your cloud network keep secret traffic off the public internet.
Turn on data access logs in your cloud project to track every secret read. Review those logs often to spot odd build activity or broad role grants.
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 we stop feature branches from reading production secrets?
Check the branch claim inside your cloud workload identity pool mapping rules. Grant production secret roles only when the token claim matches your protected main branch.
Should we use shared runners or private runners for secret fetches?
Private runners give you better network control and clean memory isolation between jobs. Shared runners work for basic builds, but private runners suit strict production tasks.
How often should we rotate secrets stored in Google Cloud?
Rotate database passwords and API keys on a set schedule using cloud rotation jobs. Since pipelines fetch the latest version at run time, builds will not break.
Related guides
In this post