[go: nahoru, domu]

Skip to content

Latest commit

 

History

History

multi-backend-multi-mig-bucket-https-lb

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

HTTPS Content-Based Load Balancer Example

button

This example creates an HTTPS load balancer to forward traffic to a custom URL map. The URL map sends traffic to the region closest to you with static assets being served from a Cloud Storage bucket. The TLS key and certificate is generated by Terraform using the TLS provider.

Figure 1. diagram of Google Cloud resources

architecture diagram

Change to the example directory

[[ `basename $PWD` != multi-backend-multi-mig-bucket-https-lb ]] && cd examples/multi-backend-multi-mig-bucket-https-lb/

Install Terraform

  1. Install Terraform if it is not already installed (visit terraform.io for other distributions):

Set up the environment

  1. Set the project, replace YOUR_PROJECT with your project ID:
PROJECT=YOUR_PROJECT
gcloud config set project ${PROJECT}
  1. Configure the environment for Terraform:
[[ $CLOUD_SHELL ]] || gcloud auth application-default login
export GOOGLE_PROJECT=$(gcloud config get-value project)

Run Terraform

terraform init
terraform apply

Testing

  1. Open URL of load balancer in browser:
echo http://$(terraform output load-balancer-ip)| sed 's/"//g'

You should see the GCP logo and instance details from the group closest to your geographical region.

  1. Open URL to route mapped to us-west1 instance group:
echo http://$(terraform output load-balancer-ip)/group1/ | sed 's/"//g'

You should see the GCP logo and instance details from the group in us-west1.

  1. Open URL to route mapped to us-central1 instance group:
echo http://$(terraform output load-balancer-ip)/group2/ | sed 's/"//g'

You should see the GCP logo and instance details from the group in us-central1.

  1. Open URL to route mapped to us-east1 instance group:
echo http://$(terraform output load-balancer-ip)/group3/ | sed 's/"//g'

You should see the GCP logo and instance details from the group in us-east1.

Cleanup

  1. Remove all resources created by terraform:
terraform destroy

Inputs

Name Description Type Default Required
group1_region n/a string "us-west1" no
group2_region n/a string "us-central1" no
group3_region n/a string "us-east1" no
network_name n/a string "ml-bk-ml-mig-bkt-s-lb" no
project n/a string n/a yes

Outputs

Name Description
asset-url n/a
asset-url-ipv6 The asset url over IPv6 address of the load-balancer, if enabled; else "undefined"
group1_region n/a
group2_region n/a
group3_region n/a
load-balancer-ip n/a
load-balancer-ipv6 The IPv6 address of the load-balancer, if enabled; else "undefined"