This page walks through one way to run Claude apps gateway on Google Cloud. The configuration is a working example for customer-managed infrastructure rather than a supported production deployment; use it to see how the pieces fit together before adapting it to your own environment. For the platform-agnostic requirements, see the deployment guide.
oidc block changes. See Identity provider setup for per-IdP details.
What you’ll build
- Cloud Run service or GKE Deployment running the gateway container
- Artifact Registry repository for the gateway image
- Cloud SQL for PostgreSQL instance, private IP only, for the gateway’s store
- Secret Manager secrets for
gateway.yaml, the JWT signing key, the OIDC client secret, and the Postgres URL - Service account with
roles/aiplatform.user, attached directly on Cloud Run or bound via Workload Identity on GKE - HTTPS front end that you provide: an internal Application Load Balancer in front of Cloud Run, which this walkthrough configures the gateway for but doesn’t create, or an internal GKE Ingress of class
gce-internalon GKE
Prerequisites
- A GCP project with billing enabled, and permission to create the resources above
- The
gcloudCLI, authenticated withgcloud auth login, and Docker installed locally - For the GKE track:
kubectl, and a GKE cluster on the VPC created in the walkthrough below - Access to the Claude models you need in Model Garden, in a region that publishes them
- A Google Workspace OAuth 2.0 web-application client with redirect URI
https://<gateway-host>/oauth/callback; see Identity provider setup - A TLS hostname for the gateway, typically an internal DNS name pointing at the load balancer
Deploy the gateway
The steps below provision the full deployment withgcloud commands.
1
Enable APIs
Enable the service APIs the walkthrough uses:The APIs you need depend on the deployment path:
computeandservicenetworking: needed for the private-IP Cloud SQL pathrun: Cloud Run onlycontainer: GKE only
2
Create the service account and grant IAM
The gateway runs as a dedicated service account with permission to call Google Cloud’s Agent Platform. It reaches Cloud SQL over the VPC with a password user, so no Cloud SQL IAM role is required:Then enable the Claude models for the project in Model Garden; models publish to specific regions, so check each model card.
3
Build and push the image to Artifact Registry
Build the image per the container image requirements, using the
linux-x64 glibc binary, and push it:4
Provision Cloud SQL for PostgreSQL
Create the instance on a VPC via Private Services Access so it has no public IP; this also satisfies projects where The Cloud Run or GKE runtime must be on, or routed into, this VPC.
constraints/sql.restrictPublicIp is enforced:5
Write gateway.yaml
The
upstreams block points at Google Cloud’s Agent Platform with auth: {}, so the gateway authenticates via Application Default Credentials from the runtime service account. See the configuration reference for every field.Two listen fields describe what fronts the gateway:public_url: the externalhttps://origin, required for any non-loopback bind; see thelistenreference. The gateway builds the IdPredirect_uriand its discovery document only from this value, never fromX-Forwarded-*headers.trusted_proxies: the front end’s source ranges. The gateway honorsX-Forwarded-Foronly when the TCP peer is in this list, then walks the chain past trusted hops, so per-IP sign-in rate limits and audit events record developer IPs instead of the load balancer’s.
trusted_proxies to match your front end. An external GKE Ingress of class gce isn’t listed: it provisions a public forwarding-rule address, which the /login private-network check rejects.The example below uses the internal-load-balancer-in-front-of-Cloud-Run values.
gateway.yaml
Google id_tokens carry no
groups claim. To use group-based policies in managed.policies with Google Workspace as the IdP, configure oidc.google_groups, which looks up each user’s groups through the Admin SDK Directory API using a service account with domain-wide delegation. Without it, match on email_domain instead.6
Store secrets in Secret Manager
Create four secrets and grant
roles/secretmanager.secretAccessor to the claude-gateway service account:How the secrets reach the container differs by track:
- On GKE they mount as files via the Secret Manager CSI driver, and
gateway.yamlreferences${file:/secrets/...}. - On Cloud Run, which can’t mount multiple secrets into one directory,
gateway.yamlmounts as a file and the other three inject as environment variables, sogateway.yamlreferences${GATEWAY_JWT_SECRET},${OIDC_CLIENT_SECRET}, and${GATEWAY_POSTGRES_URL}instead.
7
Deploy
- Cloud Run
- GKE
The command below deploys for production behind an internal load balancer.Direct VPC egress, via
--network, --subnet, and --vpc-egress=private-ranges-only, lets the service reach the Cloud SQL private IP directly. Each instance holds up to store.max_connections Postgres connections, five by default, so keep maximum instances × store.max_connections below your Cloud SQL tier’s connection limit; the reference assets cap instances at 8 for the db-g1-small tier for this reason. Public egress to Google Cloud’s Agent Platform endpoints and accounts.google.com goes directly to the internet rather than through the VPC, so no Cloud NAT is needed.The invoker IAM check must be open or disabled. The gateway runs its own OIDC and its clients carry no GCP token, so Cloud Run’s invoker check has to admit unauthenticated requests. The gateway’s OIDC sign-in authenticates the request once it reaches the container, with allowed_email_domains gating which domains may sign in.Two flags admit unauthenticated requests:--no-invoker-iam-check: disables the check with noallUsersbinding to manage, and works under Domain Restricted Sharing--allow-unauthenticated: grantsallUserstherun.invokerrole; use it if your organization doesn’t allow--no-invoker-iam-check
--ingress is a separate, independent layer from the invoker check; keep it set to limit the service to your corporate network.By default the Cloud Run *.run.app URL resolves to a public address, which the /login private-network check rejects. Two topologies give developers a privately resolvable hostname, and Cloud Run provisions neither for you:- Internal Application Load Balancer, the topology this page’s
gateway.yamlassumes: provision an internal Application Load Balancer in front of the service with an internal DNS name and certificate, and setlisten.public_urlto that hostname. Theinternalingress setting already admits traffic from internal Application Load Balancers;internal-and-cloud-load-balancingadditionally admits external Application Load Balancers, whose public addresses the/loginprivate-network check rejects, so no topology on this page needs it. - Internal-only ingress with no load balancer: keep the deploy command as is and leave
listen.public_urlas the*.run.appURL, the default in the reference assets below. For*.run.appto resolve privately, your network team must already operate a Private Service Connect endpoint for Google APIs, a Cloud DNS private zone resolving*.run.appto it, and on-premises routing to that endpoint.
<public_url>/oauth/callback before the first sign-in. Redeploy after changing public_url, because the gateway builds its public origin only from that setting and ignores X-Forwarded-Host and X-Forwarded-Proto. X-Forwarded-For is honored for client IPs only when listen.trusted_proxies is set.8
Push the gateway URL to developer machines
The gateway is now running, but developers can’t reach it from
/login until the gateway URL is on their machines. Deploy the full managed settings snippet, with forceLoginMethod, forceLoginGatewayUrl, and the parentSettingsBehavior: "merge" opt-in, to each device via MDM. There is no gateway option in the login picker for a developer to select manually.Terraform reference
The reference deployment assets automate the Cloud Run track on this page; the config and image assets apply to both tracks:setup.sh: an idempotentgcloudprovisioner that walks the full Cloud Run path, from enabling APIs through the first deployterraform/: the same deployment as infrastructure-as-code, for a greenfield deploy: a targeted apply to create the Artifact Registry repo, then build and push the image, then a full applygateway.yaml.exampleand aDockerfilefor the distroless runtime image
internal, matching the deploy command on this page; that setting works with or without an internal Application Load Balancer in front of the service, and the artifacts don’t create the load balancer either. The artifacts also default the invoker layer to an allUsers run.invoker grant rather than --no-invoker-iam-check, the inverse of this page’s walkthrough; either works, and the choice depends on your organization’s policy constraints.
The assets are provided as working examples, not as a supported production artifact; review and adapt them to your environment.
Troubleshooting
For gateway boot and login errors, see the platform-agnostic troubleshooting table. The entries below are specific to Google Cloud.Next steps
- Configuration reference: every
gateway.yamloption, includingmanaged.policiesandtelemetry - Deployment and operations: IdP setup, health checks, JWT secret rotation, upgrades, and the security model
- Claude apps gateway overview: quickstart and connecting developers