https://github.com/ahmetb/cloud-run-multi-region-terraform
Deploy a Cloud Run app to all available regions using Terraform.
https://github.com/ahmetb/cloud-run-multi-region-terraform
Last synced: about 2 months ago
JSON representation
Deploy a Cloud Run app to all available regions using Terraform.
- Host: GitHub
- URL: https://github.com/ahmetb/cloud-run-multi-region-terraform
- Owner: ahmetb
- License: apache-2.0
- Created: 2020-11-18T23:38:02.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-19T06:27:46.000Z (over 2 years ago)
- Last Synced: 2024-11-08T21:15:11.182Z (3 months ago)
- Language: HCL
- Homepage:
- Size: 16.6 KB
- Stars: 81
- Watchers: 5
- Forks: 16
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - ahmetb/cloud-run-multi-region-terraform - Deploy a Cloud Run app to all available regions using Terraform. (HCL)
README

# Multi-Region Cloud Run load balancing with Terraform
This is the **Terraform equivalent** of the [Serving traffic from multiple
regions](https://cloud.google.com/run/docs/multiple-regions) tutorial I
published on Cloud Run documentation.This example uses [Terraform
serverless_negs](https://github.com/terraform-google-modules/terraform-google-lb-http/tree/master/modules/serverless_negs)
module to deploy a Cloud Run service to [all
locations](https://cloud.google.com/run/docs/locations) and then create a global
Cloud HTTP Load Balancer with an anycast IP address to route your users to the
**nearest Cloud Run location**.## Try it out
1. Initialize terraform modules:
```sh
terraform init
```1. See the execution plan (replace `PROJECT_ID` with yours)
```sh
terraform plan -var=name=zoneprinter -var=project_id=PROJECT_ID
```1. Apply the resources. (replace `PROJECT_ID` with yours)
```sh
terraform apply -var=name=zoneprinter -var=project_id=PROJECT_ID
```1. After deploying, it will print the load balancer’s IP address.
```sh
url = http://34.107.196.62
```After waiting several minutes, the load balancer configuration will
propagate globally and start working.1. Users around the world will be connected to the **nearest Cloud Run
location** that has the application deployed when they hit the load balancer.For example, a visitor from USA may see:
```text
Welcome from Google Cloud datacenters at:
The Dalles, Oregon, USA ("us-west1").
```And a visitor from Thailand might see:
```text
Welcome from Google Cloud datacenters at:
Jurong West, Singapore ("asia-southeast1").
```1. Clean up after you’re done:
```sh
terraform destroy -var=name=zoneprinter -var=project_id=PROJECT_ID
```----
This is not an official project and does not come with maintenance guarantees.