The Simplest Way to Make Cloud Run and GitLab CI Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

You pair cloud run and gitlab ci to build and ship containers on every commit. GitLab runners pack your code into images and push updates to Google Cloud servers. This setup removes manual releases from your daily dev work. Your team commits code to a branch, and the pipeline handles the rest. When set up well, each job gets only the rights it needs to ship. How cloud run and gitlab ci share identity and data The link between cloud run and gitlab ci starts with trust between two platforms. G

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 cloud run and gitlab ci to build and ship containers on every commit. GitLab runners pack your code into images and push updates to Google Cloud servers.

This setup removes manual releases from your daily dev work. Your team commits code to a branch, and the pipeline handles the rest. When set up well, each job gets only the rights it needs to ship.

How cloud run and gitlab ci share identity and data

The link between cloud run and gitlab ci starts with trust between two platforms. GitLab runners need a safe way to log in to your Google Cloud project. The best method uses open identity standards instead of static secret keys. When a pipeline job starts, GitLab creates a short identity token for that run.

The runner sends this token to Google Cloud to prove who it is. Google Cloud checks the token against a trust rule that you set up. If the repo and branch match your rule, Google grants a brief work token. The runner then pushes the container image to the registry and updates the service.

Data flows in a clear, one-way path during this build and ship step. Source code stays in your repo while built images move to the cloud registry. Once the new revision starts, the cloud platform sends health status back to GitLab. Your team sees right away if the new container took traffic or failed.

Common failure modes and how to scope roles

Many teams start by making a single service account with broad owner rights. They download a static JSON key and paste it into the GitLab settings. This shortcut creates a major risk for your whole cloud project. Static keys do not expire unless someone on your team rotates them by hand.

If a runner leaks that key in a build log, anyone can use it. Shared service accounts also ruin your audit logs during an incident check. When ten repos use one account, you cannot tell which job broke a service. Every action looks the same inside your cloud activity log.

GitLab CI Security + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

You can fix this by giving each repo its own distinct service account. Grant each account only the exact role needed to deploy one specific service. Bind your identity trust rule to a single repo path and main branch. Pull request jobs from test branches should not get rights to touch live services.

How to lock down network paths and runtime data

Shipping the container is only half of the security work for your team. Once your app runs, it needs to talk to databases and internal services. Teams often pass raw database passwords into the container through GitLab variables. Anyone who can read the pipeline settings or cloud details can see those secrets.

A better design keeps raw database credentials out of your build pipelines. Let the cloud platform load secrets at runtime using the container identity itself. You should also lock down network paths between your runners and cloud services. Use private runner pools when your deploy step needs to run database tasks.

Check that your logs capture every deploy action and database query with user context. You also need to watch what sensitive data comes back in query results. Data masking rewrites matched fields like emails, phone numbers, card numbers, or national IDs. This keeps private user details safe during live checks and pipeline test runs.

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

Should we store Google Cloud JSON keys in GitLab variables?

No, static JSON keys stay valid forever and create a high leak risk. Use open identity tokens so each pipeline job gets a brief, scoped login instead.

How do we stop feature branches from shipping to live services?

Set up a branch rule in both GitLab and your Google Cloud trust settings. Only allow tokens from your main branch to assume the live deploy role.

Why do our cloud audit logs show the same user for all deploys?

Your pipelines share one service account across many repos or build jobs. Create a separate service account for each app so logs show exact job origins.

The query runs. The emails stay hidden.