The Simplest Way to Make Bitbucket and GCP Secret Manager Work Like They Should
Teams pair bitbucket and gcp secret manager to pull app secrets during build runs. This setup lets build jobs read keys without saving static passwords in code. In production, build runners need safe ways to get database passwords and API keys. Hardcoding those values in git repos creates huge risks for your whole team. Linking your git host with a cloud vault fixes this storage problem fast. The build runner asks the cloud vault for the exact value it needs. When the build ends, the runner dro
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 pair bitbucket and gcp secret manager to pull app secrets during build runs. This setup lets build jobs read keys without saving static passwords in code.
In production, build runners need safe ways to get database passwords and API keys. Hardcoding those values in git repos creates huge risks for your whole team. Linking your git host with a cloud vault fixes this storage problem fast. The build runner asks the cloud vault for the exact value it needs. When the build ends, the runner drops the value from memory right away.
How bitbucket and gcp secret manager share data
The link between bitbucket and gcp secret manager relies on OpenID Connect tokens. You do not need to save long-lived cloud keys inside your repo settings. Instead, the build runner makes a short-lived identity token for each job run. It sends this token to the Google Cloud workload identity pool for checks. Google Cloud checks the token claims against your trust rules and repo names.
Once the check passes, Google Cloud gives the runner a temporary cloud token. The runner uses this new token to call the secret manager API directly. It asks for one specific secret version needed for the current build step. The cloud vault checks the role permissions tied to that workload identity pool. If the role allows read rights, the vault sends the secret payload back. Every read request writes a full entry inside the cloud audit log.
Common failure modes and how to scope roles
Many teams make mistakes when they first set up this cloud link. The most common trap is using one shared service account for all repos. If every repo uses the same account, any build can read any secret. A test branch could grab production database keys and print them in logs. Another common flaw is skipping attribute checks on the identity pool trust rule.
Without strict attribute checks, other accounts on the git host might spoof tokens. You must lock down the trust rule to your exact workspace and repo. You can also check the branch identifier before granting access to production secrets. Map each repo to a distinct service account with very narrow read roles. Grant read rights on single secrets rather than the whole cloud project.
GCP Secret Manager + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Shared static keys are another big problem that teams must fix right away. Engineers often paste JSON service account keys into repo variables to save time. Those keys never expire on their own and often leak in build logs. Switching to federated identity tokens removes static keys from your build settings forever. You also need to check how build scripts handle secret values in memory. Make sure build logs mask sensitive values like emails, phone numbers, or keys.
Managing secret rotation and audit checks
Good secret hygiene does not stop once your build pipeline runs without errors. Teams must rotate stored keys and passwords on a regular schedule every month. Google Cloud lets you add new versions to a secret slot at any time. Your build jobs should pull the latest enabled version or a pinned number. Pinning a version helps stop sudden build breaks when a team updates keys.
After you deploy the new key, disable the old secret version right away. Check your cloud audit logs each week to spot weird secret read patterns. Look for builds that run at odd hours or pull too many keys. Tying build job IDs to cloud log entries makes incident reviews much faster. Clear logs show which commit triggered a secret read and when it happened.
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
Do I need to store a Google Cloud JSON key in Bitbucket?
No, you should use OpenID Connect federation instead of static JSON keys. The build runner trades a short-lived identity token for a temporary cloud token.
How do I stop feature branches from reading production secrets?
Set up deployment rules in your repo and map them to distinct roles. Check the branch claim in Google Cloud before allowing any secret read calls.
What happens if a build script prints a secret in the log?
Secret values printed in plain text can be seen by anyone with log access. Rotate the leaked secret version right away and fix the noisy build script.
Related guides
In this post