From f5bf838b0283b2b26bf8669040a0a7157b42c3e5 Mon Sep 17 00:00:00 2001 From: Dana Hoffman Date: Mon, 19 Dec 2016 11:49:49 -0800 Subject: [PATCH] Add README/output/example vars to ILB example --- examples/internal-load-balancing/README.md | 38 +++++++++++++++++++ examples/internal-load-balancing/output.tf | 3 ++ .../terraform.tfvars.example | 5 +++ 3 files changed, 46 insertions(+) create mode 100644 examples/internal-load-balancing/README.md create mode 100644 examples/internal-load-balancing/output.tf create mode 100644 examples/internal-load-balancing/terraform.tfvars.example diff --git a/examples/internal-load-balancing/README.md b/examples/internal-load-balancing/README.md new file mode 100644 index 00000000..732e3eeb --- /dev/null +++ b/examples/internal-load-balancing/README.md @@ -0,0 +1,38 @@ +# Internal Load Balancing in Google Cloud + +This provides a template for setting up internal load balancing in Google Cloud. It directly mirrors the tutorial in the [GCP Internal Load Balancing Documentation](https://cloud.google.com/compute/docs/load-balancing/internal/). + +To run the example, you'll need to [download your credentials from Google Cloud Console](https://www.terraform.io/docs/providers/google/#credentials). A suggested path for the downloaded file is `~/.gcloud/Terraform.json`. + +Optionally update `variables.tf` to specify a default value for the `project_name` variable, and check other variables. + +After you run `terraform apply` on this configuration, it will +automatically output the internal IP address of the load balancer. + +Since the load balancer is only reachable from within the network, ssh into the standalone instance using + +``` +gcloud compute ssh --zone us-central1-b standalone-instance-1 +``` + + +Using `curl` on the IP address given, the LB should respond with a simple header: + +```html +

ilb-instance-X

+``` + +To run, configure your Google Cloud provider as described in + +https://www.terraform.io/docs/providers/google/index.html + +Run with a command like this: + +``` +terraform apply \ + -var="region=us-central1" \ + -var="region_zone=us-central1-b" \ + -var="region_zone_2=us-central1-c" \ + -var="project_name=my-project-id-123" \ + -var="credentials_file_path=~/.gcloud/Terraform.json" +``` \ No newline at end of file diff --git a/examples/internal-load-balancing/output.tf b/examples/internal-load-balancing/output.tf new file mode 100644 index 00000000..97d64fbd --- /dev/null +++ b/examples/internal-load-balancing/output.tf @@ -0,0 +1,3 @@ +output "internal_load_balancer_ip" { + value = "${google_compute_forwarding_rule.my-int-lb-forwarding-rule.ip_address}" +} diff --git a/examples/internal-load-balancing/terraform.tfvars.example b/examples/internal-load-balancing/terraform.tfvars.example new file mode 100644 index 00000000..647b8e40 --- /dev/null +++ b/examples/internal-load-balancing/terraform.tfvars.example @@ -0,0 +1,5 @@ +region = "us-central1" +region_zone = "us-central1-b" +region_zone2 = "us-central1-c" +project_name = "my-project-id-123" +credentials_file_path = "~/.gcloud/Terraform.json"