From 0d7243979b67281e36aa274c0c76ca74f204340e Mon Sep 17 00:00:00 2001 From: Ludo Date: Wed, 21 Dec 2022 13:12:15 +0100 Subject: [PATCH] revert last commit --- modules/net-ilb-l7/README.md | 46 ++++++++----------- modules/net-ilb-l7/main.tf | 6 +-- modules/net-ilb-l7/variables.tf | 4 +- .../net_ilb_l7/fixture/test.negs.tfvars | 12 ++--- 4 files changed, 29 insertions(+), 39 deletions(-) diff --git a/modules/net-ilb-l7/README.md b/modules/net-ilb-l7/README.md index 3d9a81160..1ba2c33dd 100644 --- a/modules/net-ilb-l7/README.md +++ b/modules/net-ilb-l7/README.md @@ -246,13 +246,11 @@ module "ilb-l7" { my-neg = { gce = { zone = "europe-west1-b" - endpoints = { - e-0 = { - instance = "test-1" - ip_address = "10.0.0.10" - port = 80 - } - } + endpoints = [{ + instance = "test-1" + ip_address = "10.0.0.10" + port = 80 + }] } } } @@ -285,12 +283,10 @@ module "ilb-l7" { my-neg = { hybrid = { zone = "europe-west1-b" - endpoints = { - e-0 = { - ip_address = "10.0.0.10" - port = 80 - } - } + endpoints = [{ + ip_address = "10.0.0.10" + port = 80 + }] } } } @@ -516,24 +512,20 @@ module "ilb-l7" { neg-nginx-ew8-c = { gce = { zone = "europe-west8-c" - endpoints = { - e-0 = { - instance = "nginx-ew8-c" - ip_address = "10.24.32.26" - port = 80 - } - } + endpoints = [{ + instance = "nginx-ew8-c" + ip_address = "10.24.32.26" + port = 80 + }] } } neg-home-hello = { hybrid = { zone = "europe-west8-b" - endpoints = { - e-0 = { - ip_address = "192.168.0.3" - port = 443 - } - } + endpoints = [{ + ip_address = "192.168.0.3" + port = 443 + }] } } } @@ -605,7 +597,7 @@ module "ilb-l7" { | [group_configs](variables.tf#L36) | Optional unmanaged groups to create. Can be referenced in backends via key or outputs. | map(object({…})) | | {} | | [health_check_configs](variables-health-check.tf#L19) | Optional auto-created health check configurations, use the output self-link to set it in the auto healing policy. Refer to examples for usage. | map(object({…})) | | {…} | | [labels](variables.tf#L48) | Labels set on resources. | map(string) | | {} | -| [neg_configs](variables.tf#L59) | Optional network endpoint groups to create. Can be referenced in backends via key or outputs. | map(object({…})) | | {} | +| [neg_configs](variables.tf#L59) | Optional network endpoint groups to create. Can be referenced in backends via key or outputs. | map(object({…})) | | {} | | [network_tier_premium](variables.tf#L119) | Use premium network tier. Defaults to true. | bool | | true | | [ports](variables.tf#L126) | Optional ports for HTTP load balancer, valid ports are 80 and 8080. | list(string) | | null | | [protocol](variables.tf#L137) | Protocol supported by this load balancer. | string | | "HTTP" | diff --git a/modules/net-ilb-l7/main.tf b/modules/net-ilb-l7/main.tf index 49c4762df..5b6211a39 100644 --- a/modules/net-ilb-l7/main.tf +++ b/modules/net-ilb-l7/main.tf @@ -15,10 +15,9 @@ */ locals { - # we need keys in the endpoint type to address issue #1055 _neg_endpoints = flatten([ for k, v in local.neg_zonal : [ - for kk, vv in v.endpoints : merge(vv, { neg = k, key = "${k}-${kk}", zone = v.zone }) + for vv in v.endpoints : merge(vv, { neg = k, zone = v.zone }) ] ]) fwd_rule_ports = ( @@ -30,7 +29,8 @@ locals { : google_compute_region_target_http_proxy.default.0.id ) neg_endpoints = { - for v in local._neg_endpoints : (v.key) => v + for v in local._neg_endpoints : + "${v.neg}-${v.ip_address}-${coalesce(v.port, "none")}" => v } neg_regional = { for k, v in var.neg_configs : diff --git a/modules/net-ilb-l7/variables.tf b/modules/net-ilb-l7/variables.tf index 09b3f7ac7..0577ddf6e 100644 --- a/modules/net-ilb-l7/variables.tf +++ b/modules/net-ilb-l7/variables.tf @@ -73,7 +73,7 @@ variable "neg_configs" { # default_port = optional(number) network = optional(string) subnetwork = optional(string) - endpoints = optional(map(object({ + endpoints = optional(list(object({ instance = string ip_address = string port = number @@ -85,7 +85,7 @@ variable "neg_configs" { network = optional(string) # re-enable once provider properly support this # default_port = optional(number) - endpoints = optional(map(object({ + endpoints = optional(list(object({ ip_address = string port = number }))) diff --git a/tests/modules/net_ilb_l7/fixture/test.negs.tfvars b/tests/modules/net_ilb_l7/fixture/test.negs.tfvars index f6141a7ef..2f7f48d57 100644 --- a/tests/modules/net_ilb_l7/fixture/test.negs.tfvars +++ b/tests/modules/net_ilb_l7/fixture/test.negs.tfvars @@ -9,13 +9,11 @@ neg_configs = { custom = { gce = { zone = "europe-west1-b" - endpoints = { - e-0 = { - ip_address = "10.0.0.10" - instance = "test-1" - port = 80 - } - } + endpoints = [{ + ip_address = "10.0.0.10" + instance = "test-1" + port = 80 + }] } } }