From f49515495c5bb9d4d67a9a90261ac1698af8f5b1 Mon Sep 17 00:00:00 2001 From: Miren Esnaola Date: Mon, 31 Jul 2023 10:14:05 +0200 Subject: [PATCH] Fix in validation of healthchecks variable --- modules/net-lb-app-ext/variables-health-check.tf | 5 ++++- modules/net-lb-app-int/variables-health-check.tf | 5 ++++- modules/net-lb-ext/README.md | 14 ++++++-------- modules/net-lb-ext/variables.tf | 5 ++++- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/modules/net-lb-app-ext/variables-health-check.tf b/modules/net-lb-app-ext/variables-health-check.tf index bfb8b67b2..be34d779d 100644 --- a/modules/net-lb-app-ext/variables-health-check.tf +++ b/modules/net-lb-app-ext/variables-health-check.tf @@ -88,7 +88,10 @@ variable "health_check_configs" { for k, v in var.health_check_configs : ( (try(v.grpc, null) == null ? 0 : 1) + (try(v.http, null) == null ? 0 : 1) + - (try(v.tcp, null) == null ? 0 : 1) <= 1 + (try(v.http2, null) == null ? 0 : 1) + + (try(v.https, null) == null ? 0 : 1) + + (try(v.tcp, null) == null ? 0 : 1) + + (try(v.ssl, null) == null ? 0 : 1) <= 1 ) ]) error_message = "At most one health check type can be configured at a time." diff --git a/modules/net-lb-app-int/variables-health-check.tf b/modules/net-lb-app-int/variables-health-check.tf index f56d02304..a51994ecf 100644 --- a/modules/net-lb-app-int/variables-health-check.tf +++ b/modules/net-lb-app-int/variables-health-check.tf @@ -88,7 +88,10 @@ variable "health_check_configs" { for k, v in var.health_check_configs : ( (try(v.grpc, null) == null ? 0 : 1) + (try(v.http, null) == null ? 0 : 1) + - (try(v.tcp, null) == null ? 0 : 1) <= 1 + (try(v.http2, null) == null ? 0 : 1) + + (try(v.https, null) == null ? 0 : 1) + + (try(v.tcp, null) == null ? 0 : 1) + + (try(v.ssl, null) == null ? 0 : 1) <= 1 ) ]) error_message = "Only one health check type can be configured at a time." diff --git a/modules/net-lb-ext/README.md b/modules/net-lb-ext/README.md index 44bb0605f..faea7c73b 100644 --- a/modules/net-lb-ext/README.md +++ b/modules/net-lb-ext/README.md @@ -151,14 +151,13 @@ module "nlb" { # tftest modules=3 resources=7 ``` - ## Variables | name | description | type | required | default | |---|---|:---:|:---:|:---:| -| [name](variables.tf#L186) | Name used for all resources. | string | ✓ | | -| [project_id](variables.tf#L197) | Project id where resources will be created. | string | ✓ | | -| [region](variables.tf#L213) | GCP region. | string | ✓ | | +| [name](variables.tf#L189) | Name used for all resources. | string | ✓ | | +| [project_id](variables.tf#L200) | Project id where resources will be created. | string | ✓ | | +| [region](variables.tf#L216) | GCP region. | string | ✓ | | | [address](variables.tf#L17) | Optional IP address used for the forwarding rule. | string | | null | | [backend_service_config](variables.tf#L23) | Backend service level configuration. | object({…}) | | {} | | [backends](variables.tf#L72) | Load balancer backends, balancing mode is one of 'CONNECTION' or 'UTILIZATION'. | list(object({…})) | | [] | @@ -166,9 +165,9 @@ module "nlb" { | [group_configs](variables.tf#L89) | Optional unmanaged groups to create. Can be referenced in backends via outputs. | map(object({…})) | | {} | | [health_check](variables.tf#L100) | Name of existing health check to use, disables auto-created health check. | string | | null | | [health_check_config](variables.tf#L106) | Optional auto-created health check configuration, use the output self-link to set it in the auto healing policy. Refer to examples for usage. | object({…}) | | {…} | -| [labels](variables.tf#L180) | Labels set on resources. | map(string) | | {} | -| [ports](variables.tf#L191) | Comma-separated ports, leave null to use all ports. | list(string) | | null | -| [protocol](variables.tf#L202) | IP protocol used, defaults to TCP. UDP or L3_DEFAULT can also be used. | string | | "TCP" | +| [labels](variables.tf#L183) | Labels set on resources. | map(string) | | {} | +| [ports](variables.tf#L194) | Comma-separated ports, leave null to use all ports. | list(string) | | null | +| [protocol](variables.tf#L205) | IP protocol used, defaults to TCP. UDP or L3_DEFAULT can also be used. | string | | "TCP" | ## Outputs @@ -186,5 +185,4 @@ module "nlb" { | [health_check_self_id](outputs.tf#L64) | Auto-created health-check self id. | | | [health_check_self_link](outputs.tf#L69) | Auto-created health-check self link. | | | [id](outputs.tf#L74) | Fully qualified forwarding rule id. | | - diff --git a/modules/net-lb-ext/variables.tf b/modules/net-lb-ext/variables.tf index 58ae663af..dbc9b54cc 100644 --- a/modules/net-lb-ext/variables.tf +++ b/modules/net-lb-ext/variables.tf @@ -171,7 +171,10 @@ variable "health_check_config" { condition = ( (try(var.health_check_config.grpc, null) == null ? 0 : 1) + (try(var.health_check_config.http, null) == null ? 0 : 1) + - (try(var.health_check_config.tcp, null) == null ? 0 : 1) <= 1 + (try(var.health_check_config.http2, null) == null ? 0 : 1) + + (try(var.health_check_config.https, null) == null ? 0 : 1) + + (try(var.health_check_config.tcp, null) == null ? 0 : 1) + + (try(var.health_check_config.ssl, null) == null ? 0 : 1) <= 1 ) error_message = "Only one health check type can be configured at a time." }