diff --git a/docs/upgrading_to_lb_internal_v7.0.md b/docs/upgrading_to_lb_internal_v7.0.md new file mode 100644 index 0000000..3c21b5a --- /dev/null +++ b/docs/upgrading_to_lb_internal_v7.0.md @@ -0,0 +1,64 @@ +# Upgrading to v7.0 (from v6.x) + +The v7.0 release is a backwards incompatible release. + +# balancing_mode for backends + +The newest version of `google_compute_region_backend_service` requires a `balancing_mode` be set for backends. Therefore a default `balancing_mode` of `CONNECTION` is used in the dynamic `backend` block in v7.0 of this module. The full list of balancing modes is available in the [documentation](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_backend_service#balancing_mode). + +## Upgrade Guidance + +In this example, `balancing_mode` is *not* provided in the `backends` block. Therefore, it will default to `CONNECTION`. + +```hcl +module "gce_ilb" { + source = "GoogleCloudPlatform/lb-internal/google" + version = ">= 4.4.0" + project = var.project_id + region = var.region + name = "tf-ilb" + network = "testnetwork" + subnetwork = "testsubnet" + ports = ["xxxx"] + health_check = local.health_check + source_tags = ["xxxxxx"] + target_tags = ["xxxxxx"] + backends = [ + for x in google_compute_instance_group.test_ig[*] : { + group = x.id + description = "" + failover = false + } + ] + create_backend_firewall = "true" + create_health_check_firewall = "true" +} +``` + +This is an example where the `balancing_mode` is explicitly provided: + +```hcl +module "gce_ilb" { + source = "GoogleCloudPlatform/lb-internal/google" + version = ">= 4.4.0" + project = var.project_id + region = var.region + name = "tf-ilb" + network = "testnetwork" + subnetwork = "testsubnet" + ports = ["xxxx"] + health_check = local.health_check + source_tags = ["xxxxxx"] + target_tags = ["xxxxxx"] + backends = [ + for x in google_compute_instance_group.test_ig[*] : { + group = x.id + description = "" + failover = false + balancing_mode = "CONNECTION" + } + ] + create_backend_firewall = "true" + create_health_check_firewall = "true" +} +``` diff --git a/main.tf b/main.tf index 60272a6..2702b0b 100644 --- a/main.tf +++ b/main.tf @@ -58,12 +58,14 @@ resource "google_compute_region_backend_service" "default" { # Do not try to add timeout_sec, as it is has no impact. See https://github.com/terraform-google-modules/terraform-google-lb-internal/issues/53#issuecomment-893427675 connection_draining_timeout_sec = var.connection_draining_timeout_sec session_affinity = var.session_affinity + dynamic "backend" { for_each = var.backends content { - group = lookup(backend.value, "group", null) - description = lookup(backend.value, "description", null) - failover = lookup(backend.value, "failover", null) + group = lookup(backend.value, "group", null) + description = lookup(backend.value, "description", null) + failover = lookup(backend.value, "failover", null) + balancing_mode = lookup(backend.value, "balancing_mode", "CONNECTION") } } health_checks = concat(google_compute_health_check.tcp[*].self_link, google_compute_health_check.http[*].self_link, google_compute_health_check.https[*].self_link)