docs/platform/infrastructure/gcp-static-ip.md
By default, Cloud Run services send outbound traffic to the internet using a pool of Google-owned IP addresses that changes over time. This makes it impossible for a third party to allowlist your application's traffic.
To get a stable outbound IP address, you route your services' egress traffic through your environment's VPC and out via a Cloud NAT gateway that uses a reserved static IP address.
This requires two steps:
A static outbound IP allows you to:
Encore Cloud provisions a dedicated GCP project and VPC network for each environment. The Cloud NAT gateway needs to be created in that project, in the same region as your environment.
First, reserve a static external IP address:
encore-egress-ip)Regional and select the region your environment is deployed inThen create the Cloud NAT gateway:
encore-egress-nat)PublicManual and select the static IP address you reservedCreate the Cloud NAT gateway before changing the VPC egress setting in the next step. Once egress is routed through the VPC, outbound internet traffic depends on the NAT gateway — without it, your services will not be able to reach the internet.
</Callout>By default, Cloud Run only sends traffic destined for private IP ranges through the VPC, and sends internet-bound traffic directly out via Google's IP pool. To make internet-bound traffic use the NAT gateway, you need to change the VPC egress setting:
All trafficInfrastructure changes made in the dashboard are applied as part of a deployment, so trigger a new deploy (or push a commit) for the setting to take effect. See Managing Infrastructure for details on the deployment phases.
Once deployed, make an outbound request from one of your services to a service that echoes back the caller's IP address (for example https://api.ipify.org) and confirm that the returned address matches the static IP you reserved.
All traffic egress, every outbound request — including calls to public APIs — goes through the VPC and the NAT gateway. This adds NAT data processing charges, and the NAT gateway becomes a dependency for all internet access from your services.If your environment runs on GKE instead of Cloud Run, the VPC egress setting doesn't apply — pods already egress through the VPC network. In that case, check whether a Cloud NAT gateway already exists for the network and attach a reserved static IP address to it rather than creating a second gateway.
</Callout>