This example creates a regional internal forwarding rule to forward traffic to backends in the us-central1 region.
You can add backends to the load balancer's backend service by using the gcloud compute backend-services add-backend command.
Name | Description | Type | Default | Required |
---|---|---|---|---|
project_id | The project to create test resources within. | string |
n/a | yes |
region | Region for cloud resources. | string |
"us-central1" |
no |
Name | Description |
---|---|
random_suffix | A random string generated by terraform to append to resource names. This helps avoid name collisions and the test suite consumes this value. |
[[ `basename $PWD` != minimal ]] && cd examples/minimal
- Install Terraform if it is not already installed (visit terraform.io for other distributions):
- Set the project, replace
YOUR_PROJECT
with your project ID:
PROJECT=YOUR_PROJECT
gcloud config set project ${PROJECT}
- Configure the environment for Terraform:
[[ $CLOUD_SHELL ]] || gcloud auth application-default login
export GOOGLE_PROJECT=$(gcloud config get-value project)
terraform init
terraform apply
-
Add backends to the backend service.
The backends must be in the same region and VPC network as the forwarding rule.
-
Create a client VM in the same region and VPC network.
-
SSH to the client VM and then run:
curl http://(IP address of the forwarding rule)
- Remove all resources created by terraform:
terraform destroy