The Simplest Way to Make Buildkite and Cloud Run Work Like They Should
Teams use buildkite and cloud run to build containers and run them in the cloud. Buildkite runs the test pipeline, and Cloud Run hosts the web app. This pair gives teams fast builds and quick scaling. Buildkite lets you run agents on your own machines. Cloud Run starts your app containers when web traffic arrives. Together, they move code from a git commit to a live service. How buildkite and cloud run share permissions and data The workflow starts when a developer pushes code to a repo. Bui
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 use buildkite and cloud run to build containers and run them in the cloud. Buildkite runs the test pipeline, and Cloud Run hosts the web app.
This pair gives teams fast builds and quick scaling. Buildkite lets you run agents on your own machines. Cloud Run starts your app containers when web traffic arrives. Together, they move code from a git commit to a live service.
How buildkite and cloud run share permissions and data
The workflow starts when a developer pushes code to a repo. Buildkite sees the change and starts a build job on an agent. The agent compiles the code and packs it into a container image. Next, the agent sends that image to a Google Cloud registry.
After the image upload finishes, the agent tells Cloud Run to update the service. This step needs strict login rules between the two platforms. In the past, teams stored static service account keys on build agents. Static keys create high risk because anyone who copies the key gets cloud permissions.
A safer way uses OpenID Connect to link the two tools. Buildkite issues a short job token for each build step. Google Cloud checks this token through workload identity federation. If the token matches your rules, Google grants a short cloud token. The agent uses that temporary token to push images and deploy the app. When the job ends, the token expires right away.
Common failure modes and how to scope roles
Many teams fail by giving one broad service account to every build agent. If an attacker compromises one test pipeline, they can change production apps. Another common mistake is letting any branch trigger a production deploy. Without branch checks, an unreviewed test branch can overwrite live services.
Teams also run into trouble with shared agent disks. One build job might leave secret files behind on the host machine. The next job on that agent can then read those files. You should wipe the agent workspace clean after every single build job.
End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
To fix permission risks, split your build agents into separate pools. Use one pool for running tests on pull requests. Use a locked pool only for deploying the main branch. Give each pool its own service account with small, distinct roles.
Your test pool only needs to read code and push test images. Your deploy pool gets permission to update the specific Cloud Run service. You can also set trust rules on Google Cloud to check token claims. Make sure Google checks the pipeline name and branch name before granting permissions.
Securing runtime secrets and database calls
Deploying the container is only half of the security puzzle. Once the app starts on Cloud Run, it needs to talk to databases. Teams often pass database passwords as plain text variables during the build step. This puts raw secrets inside the build logs and the container settings.
Instead, keep runtime secrets out of the Buildkite pipeline altogether. Let the Cloud Run service identity fetch what it needs at startup. Even better, make sure every database query from your team and apps gets logged. When PII like emails or card numbers returns in queries, masking rewrites matched fields in results. This keeps sensitive data safe during both deploys and daily debug work.
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
Should I store Google Cloud JSON keys in Buildkite?
No, you should avoid long-lived JSON keys in your build pipelines. Use workload identity federation so Buildkite agents trade job tokens for temporary cloud credentials.
Can Buildkite agents run inside Google Cloud?
Yes, you can run Buildkite agents on Google virtual machines or Kubernetes clusters. Placing agents in the same cloud makes image uploads to the registry much faster.
How do I stop feature branches from deploying to production?
Separate your deploy steps onto a dedicated Buildkite agent queue. Then set your Google trust rules to accept tokens only from the main branch.
Related guides
In this post