gcp-cloudrun-iap-loadbalancer

Configure Cloud Run behind an HTTPS Load Balancer with IAP and resolve JWT Client ID mismatches.

Updated Jul 7, 2026
One-click install
npx skills add https://github.com/ricardolui/gcp-custom-agent-skills --skill gcp-cloudrun-iap-loadbalancer-ricardolui
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gcp-cloudrun-iap-loadbalancer
Source: https://github.com/ricardolui/gcp-custom-agent-skills/tree/main/gcp-cloudrun-iap-loadbalancer
Command: npx skills add https://github.com/ricardolui/gcp-custom-agent-skills --skill gcp-cloudrun-iap-loadbalancer-ricardolui

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Securing Google Cloud Run behind a Global HTTPS Load Balancer with Identity-Aware Proxy often causes persistent 403 Forbidden errors when native Cloud Run IAP and Load Balancer IAP are both enabled, because their OAuth Client IDs produce mismatched JWT tokens. ## Core Features & Use Cases - Architecture Guidance: Explains the correct least-privilege pattern where IAP runs only at the Load Balancer, Cloud Run ingress is restricted to internal-and-cloud-load-balancing, and the IAP Service Agent receives roles/run.invoker. - Troubleshooting Commands: Provides gcloud commands to disable native IAP with --no-iap, re-apply the IAP Service Agent invoker binding, and enforce private ingress. - Deployment Scripting Pattern: Shows a shell script pattern using ENABLE_IAP and LOAD_BALANCER_IAP flags to skip native Cloud Run IAP when a Load Balancer handles authentication. - Use Case: A team deploys a Cloud Run service behind a custom domain with a Global HTTPS Load Balancer and hits GFE 403 errors; this Skill walks them through disabling native IAP and granting the IAP Service Agent invoker access. ## Quick Start Diagnose why my Cloud Run service behind an HTTPS Load Balancer with IAP returns 403 Forbidden errors and give me the gcloud commands to fix it.

Frequently Asked Questions about gcp-cloudrun-iap-loadbalancer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does Cloud Run return 403 Forbidden behind a Load Balancer with IAP?

The 403 occurs when both Load Balancer IAP and native Cloud Run IAP are enabled. The Load Balancer signs the JWT with its own OAuth Client ID, but native Cloud Run IAP validates against a different Google-managed Client ID, causing token validation to fail.

How do I secure Cloud Run with IAP through an HTTPS Load Balancer?

Enable IAP only on the Load Balancer backend service, set Cloud Run ingress to internal-and-cloud-load-balancing, deploy with --no-allow-unauthenticated, and grant the IAP Service Agent ([email protected]) the roles/run.invoker role.

Should I enable native Cloud Run IAP when using a Load Balancer?

No. Native Cloud Run IAP must be disabled with gcloud beta run services update --no-iap when a Load Balancer handles IAP, otherwise the two Client IDs conflict and requests fail with 403 errors.

What happens to IAM bindings when I run --no-iap on Cloud Run?

Running --no-iap resets the Cloud Run service's IAM invoker policy. You must re-apply the IAP Service Agent's roles/run.invoker binding afterward using gcloud run services add-iam-policy-binding.

How do I automate IAP configuration in a Cloud Run deploy script?

Use a LOAD_BALANCER_IAP flag in your deploy script: always grant the IAP Service Agent invoker access, but only run the native --iap update when the flag is false, skipping it when a Load Balancer handles authentication.