Terraform-Up-and-Running-Code-Samples-Translated icon indicating copy to clipboard operation
Terraform-Up-and-Running-Code-Samples-Translated copied to clipboard

GCP webserver-cluster/main.tf contains redundant resource compute_backend_service

Open simonderekhughes opened this issue 4 years ago • 0 comments

The following main.tf in this repo:

https://github.com/mjuenema/Terraform-Up-and-Running-Code-Samples-Translated/blob/develop/gcloud/code/terraform/02-intro-to-terraform-syntax/webserver-cluster/main.tf

contains this unnecessary code:

resource "google_compute_backend_service" "example" {
  name = "example-backend-service"
  port_name = "http"
  protocol = "HTTP"
  timeout_sec = 10
  enable_cdn = false

  backend {
    group = "${google_compute_instance_group_manager.example.instance_group}"
  }

  health_checks = ["${google_compute_http_health_check.example.self_link}"]
}

It can be removed and the example still works fine. This is because the Network Load Balancer does not need a backend service. In this gcp document:

https://cloud.google.com/load-balancing/docs/backend-service

it says

"Network Load Balancing does not use a backend service."

It would be good if the example referenced this document:

https://cloud.google.com/load-balancing/docs/network/setting-up-network

which describes the setup in this file.

Also note that the code has to be changed to work with 0.12.26 e.g. some self_link dont work, and some things no longer need quoting.

simonderekhughes avatar Oct 27 '20 13:10 simonderekhughes