The example creates a managed instance group with 2 instances in the same region and a network TCP Load Balancer.
To provision this example, run the following from this directory or using Cloud Shell.
[[ `basename $PWD` != basic ]] && cd examples/basic
- Set the project, replacing
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)
- Install Terraform if it is not already installed
terraform init
to download plugins and set up Terraform state
terraform plan
to see the infrastructure planterraform apply
to apply the infrastructure build Once complete, the load balancer IP address will display as an output
- Open the URL of the load balancer in your browser
echo http://$(terraform output load_balancer_default_ip)
terraform destroy
to remove all resources created by terraform
Name | Description | Type | Default | Required |
---|---|---|---|---|
image_family | Image used for compute VMs. | string |
"debian-11" |
no |
image_project | GCP Project where source image comes from. | string |
"debian-cloud" |
no |
project_id | GCP Project used to create resources. | any |
n/a | yes |
region | n/a | string |
"us-central1" |
no |
Name | Description |
---|---|
load_balancer_default_ip | The external ip address of the forwarding rule for default lb. |