The Simplest Way to Make CircleCI and Cloud Run Work Like They Should
You pair circleci and cloud run to build code and ship containers fast. CircleCI tests your app, and Cloud Run hosts the live service on Google Cloud. Together, they turn a git push into a running web app in minutes. Teams use this pair to skip server upkeep and ship code many times a day. How circleci and cloud run share permissions and data A clean pipeline needs a clear path between your build runner and your cloud host. First, a developer pushes code to a source repo. CircleCI sees this c
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 pair circleci and cloud run to build code and ship containers fast. CircleCI tests your app, and Cloud Run hosts the live service on Google Cloud. Together, they turn a git push into a running web app in minutes. Teams use this pair to skip server upkeep and ship code many times a day.
How circleci and cloud run share permissions and data
A clean pipeline needs a clear path between your build runner and your cloud host. First, a developer pushes code to a source repo. CircleCI sees this change and starts a new build job. The runner tests the code and packs the app into a container image. Next, CircleCI sends that image to a Google Cloud container registry.
To do this, the build job must log in to Google Cloud. Many teams used to store static JSON keys inside CircleCI project settings. Today, OpenID Connect lets CircleCI trade a build token for a short Google Cloud token. This trade uses Workload Identity Federation inside Google Cloud. No one has to save or rotate a long-lived secret key.
Once the image lands in the registry, CircleCI tells Cloud Run to update. Cloud Run pulls the new image and starts fresh container instances. It shifts web traffic to the new version once health checks pass. Data flows in one direction from git to CircleCI to Google Cloud.
Common failure modes and how to scope roles
Most pipeline breaks and security gaps come from broad permissions. Teams often give the CircleCI service account an editor or owner role. If an attacker steals that build token, they can control the whole cloud project. Another common trap is sharing one service account across ten different microservices. When a bad deploy happens, logs cannot show which repo caused the fault.
You can fix this by giving each repo its own Google Cloud service account. Bind Workload Identity rules to check the exact CircleCI project and git branch. Only the main branch should have rights to deploy to your live Cloud Run service. Feature branches should only push test images or deploy to staging.
End-to-End Encryption + CircleCI Security: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Scope the Google Cloud role to the bare minimum needed for the job. The build account needs rights to write images to one registry path. It also needs rights to update one specific Cloud Run service. It also needs permission to act as the Cloud Run runtime service account. Keep the build account separate from the runtime account that runs your live app.
Securing live database and service tasks during deploys
Deploys often need more than just a new container image. Many pipelines run database schema updates or check live state during a release. Running these commands straight from CircleCI opens another risky network path. Build runners live outside your private cloud network by default.
Opening your database to public build runner IPs creates a huge risk. Instead, route admin tasks and database checks through tight identity and data rules. You can also mask sensitive fields like emails, phone numbers, and card numbers in query outputs. This keeps test jobs and deploy logs clean of raw user data while keeping full audit trails.
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 use static JSON keys to log in from CircleCI to Google Cloud?
No, static keys are hard to rotate and easy to leak in build logs. Use OpenID Connect with Google Cloud Workload Identity Federation for short tokens instead.
How do I stop feature branches from shipping to live Cloud Run services?
Set attribute rules on your Google Cloud identity pool to check the git branch claim. Also use CircleCI branch filters so deploy jobs only run on your main branch.
Should CircleCI and the Cloud Run app share the same service account?
No, always split the deploy account from the runtime account. CircleCI only needs rights to push code, while the app needs rights to read cloud data.
Related guides
In this post