Skip to content

chrisfrank/cloud-run-multi-region-terraform

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi-Region Cloud Run load balancing with Terraform

This is the Terraform equivalent of the Serving traffic from multiple regions tutorial I published on Cloud Run documentation.

This example uses Terraform serverless_negs module to deploy a Cloud Run service to all 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:

    terraform init
  2. See the execution plan (replace PROJECT_ID with yours)

    terraform plan -var=name=zoneprinter -var=project_id=PROJECT_ID
  3. Apply the resources. (replace PROJECT_ID with yours)

    terraform apply -var=name=zoneprinter -var=project_id=PROJECT_ID
  4. After deploying, it will print the load balancer’s IP address.

    url = http://34.107.196.62

    After waiting several minutes, the load balancer configuration will propagate globally and start working.

  5. 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:

    Welcome from Google Cloud datacenters at:
    The Dalles, Oregon, USA ("us-west1").
    

    And a visitor from Thailand might see:

    Welcome from Google Cloud datacenters at:
    Jurong West, Singapore ("asia-southeast1").
    
  6. Clean up after you’re done:

    terraform destroy -var=name=zoneprinter -var=project_id=PROJECT_ID

This is not an official project and does not come with maintenance guarantees.

About

Deploy a Cloud Run app to all available regions using Terraform.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HCL 100.0%