From b5457fe1ee457b41ccf9881fdc3f00ca8733daf5 Mon Sep 17 00:00:00 2001 From: Krzysztof Mucha Date: Wed, 21 Sep 2022 11:38:21 +0200 Subject: [PATCH] Add support for service_label property in internal load balancer --- modules/net-ilb-l7/README.md | 22 +++++++++---------- modules/net-ilb-l7/forwarding-rule.tf | 1 + modules/net-ilb-l7/variables.tf | 12 +++++----- tests/modules/net_ilb_l7/fixture/variables.tf | 12 +++++----- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/modules/net-ilb-l7/README.md b/modules/net-ilb-l7/README.md index 5dabc52dd5..64a3f7761a 100644 --- a/modules/net-ilb-l7/README.md +++ b/modules/net-ilb-l7/README.md @@ -403,18 +403,18 @@ An Internal HTTP Load Balancer is made of multiple components, that change depen |---|---|:---:|:---:|:---:| | [name](variables.tf#L17) | Load balancer name. | string | ✓ | | | [project_id](variables.tf#L22) | Project id. | string | ✓ | | -| [region](variables.tf#L157) | The region where to allocate the ILB resources. | string | ✓ | | -| [subnetwork](variables.tf#L187) | The subnetwork where the ILB VIP is allocated. | string | ✓ | | +| [region](variables.tf#L159) | The region where to allocate the ILB resources. | string | ✓ | | +| [subnetwork](variables.tf#L189) | The subnetwork where the ILB VIP is allocated. | string | ✓ | | | [backend_services_config](variables.tf#L27) | The backends services configuration. | map(object({…})) | | {} | -| [forwarding_rule_config](variables.tf#L98) | Forwarding rule configurations. | object({…}) | | {…} | -| [health_checks_config](variables.tf#L116) | Custom health checks configuration. | map(object({…})) | | {} | -| [health_checks_config_defaults](variables.tf#L127) | Auto-created health check default configuration. | object({…}) | | {…} | -| [https](variables.tf#L145) | Whether to enable HTTPS. | bool | | false | -| [network](variables.tf#L151) | The network where the ILB is created. | string | | "default" | -| [ssl_certificates_config](variables.tf#L162) | The SSL certificates configuration. | map(object({…})) | | {} | -| [static_ip_config](variables.tf#L172) | Static IP address configuration. | object({…}) | | {…} | -| [target_proxy_https_config](variables.tf#L192) | The HTTPS target proxy configuration. | object({…}) | | null | -| [url_map_config](variables.tf#L200) | The url-map configuration. | object({…}) | | null | +| [forwarding_rule_config](variables.tf#L98) | Forwarding rule configurations. | object({…}) | | {…} | +| [health_checks_config](variables.tf#L118) | Custom health checks configuration. | map(object({…})) | | {} | +| [health_checks_config_defaults](variables.tf#L129) | Auto-created health check default configuration. | object({…}) | | {…} | +| [https](variables.tf#L147) | Whether to enable HTTPS. | bool | | false | +| [network](variables.tf#L153) | The network where the ILB is created. | string | | "default" | +| [ssl_certificates_config](variables.tf#L164) | The SSL certificates configuration. | map(object({…})) | | {} | +| [static_ip_config](variables.tf#L174) | Static IP address configuration. | object({…}) | | {…} | +| [target_proxy_https_config](variables.tf#L194) | The HTTPS target proxy configuration. | object({…}) | | null | +| [url_map_config](variables.tf#L202) | The url-map configuration. | object({…}) | | null | ## Outputs diff --git a/modules/net-ilb-l7/forwarding-rule.tf b/modules/net-ilb-l7/forwarding-rule.tf index 41044060c4..31ff652563 100644 --- a/modules/net-ilb-l7/forwarding-rule.tf +++ b/modules/net-ilb-l7/forwarding-rule.tf @@ -62,6 +62,7 @@ resource "google_compute_forwarding_rule" "forwarding_rule" { port_range = local.port_range ports = [] region = try(var.region, null) + service_label = try(var.forwarding_rule_config.service_label, null) subnetwork = try(var.subnetwork, null) target = local.target } diff --git a/modules/net-ilb-l7/variables.tf b/modules/net-ilb-l7/variables.tf index 8d9979fd96..7202e3faed 100644 --- a/modules/net-ilb-l7/variables.tf +++ b/modules/net-ilb-l7/variables.tf @@ -98,10 +98,11 @@ variable "backend_services_config" { variable "forwarding_rule_config" { description = "Forwarding rule configurations." type = object({ - ip_version = string - labels = map(string) - network_tier = string - port_range = string + ip_version = string + labels = map(string) + network_tier = string + port_range = string + service_label = string }) default = { allow_global_access = true @@ -109,7 +110,8 @@ variable "forwarding_rule_config" { labels = {} network_tier = "PREMIUM" # If not specified, 443 if var.https = true; 80 otherwise - port_range = null + port_range = null + service_label = null } } diff --git a/tests/modules/net_ilb_l7/fixture/variables.tf b/tests/modules/net_ilb_l7/fixture/variables.tf index 0e40c5c0a9..d513a2a4c4 100644 --- a/tests/modules/net_ilb_l7/fixture/variables.tf +++ b/tests/modules/net_ilb_l7/fixture/variables.tf @@ -88,10 +88,11 @@ variable "backend_services_config" { variable "forwarding_rule_config" { description = "Forwarding rule configurations." type = object({ - ip_version = string - labels = map(string) - network_tier = string - port_range = string + ip_version = string + labels = map(string) + network_tier = string + port_range = string + service_label = string }) default = { allow_global_access = true @@ -99,7 +100,8 @@ variable "forwarding_rule_config" { labels = {} network_tier = "PREMIUM" # If not specified, 443 if var.https = true; 80 otherwise - port_range = null + port_range = null + service_label = null } }