Fix in validation of healthchecks variable
This commit is contained in:
parent
1c3d47266f
commit
f49515495c
|
@ -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."
|
||||
|
|
|
@ -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."
|
||||
|
|
|
@ -151,14 +151,13 @@ module "nlb" {
|
|||
# tftest modules=3 resources=7
|
||||
```
|
||||
<!-- BEGIN TFDOC -->
|
||||
|
||||
## Variables
|
||||
|
||||
| name | description | type | required | default |
|
||||
|---|---|:---:|:---:|:---:|
|
||||
| [name](variables.tf#L186) | Name used for all resources. | <code>string</code> | ✓ | |
|
||||
| [project_id](variables.tf#L197) | Project id where resources will be created. | <code>string</code> | ✓ | |
|
||||
| [region](variables.tf#L213) | GCP region. | <code>string</code> | ✓ | |
|
||||
| [name](variables.tf#L189) | Name used for all resources. | <code>string</code> | ✓ | |
|
||||
| [project_id](variables.tf#L200) | Project id where resources will be created. | <code>string</code> | ✓ | |
|
||||
| [region](variables.tf#L216) | GCP region. | <code>string</code> | ✓ | |
|
||||
| [address](variables.tf#L17) | Optional IP address used for the forwarding rule. | <code>string</code> | | <code>null</code> |
|
||||
| [backend_service_config](variables.tf#L23) | Backend service level configuration. | <code title="object({ connection_draining_timeout_sec = optional(number) connection_tracking = optional(object({ idle_timeout_sec = optional(number) persist_conn_on_unhealthy = optional(string) track_per_session = optional(bool) })) failover_config = optional(object({ disable_conn_drain = optional(bool) drop_traffic_if_unhealthy = optional(bool) ratio = optional(number) })) locality_lb_policy = optional(string) log_sample_rate = optional(number) port_name = optional(string) protocol = optional(string, "UNSPECIFIED") session_affinity = optional(string) timeout_sec = optional(number) })">object({…})</code> | | <code>{}</code> |
|
||||
| [backends](variables.tf#L72) | Load balancer backends, balancing mode is one of 'CONNECTION' or 'UTILIZATION'. | <code title="list(object({ group = string description = optional(string, "Terraform managed.") failover = optional(bool, false) }))">list(object({…}))</code> | | <code>[]</code> |
|
||||
|
@ -166,9 +165,9 @@ module "nlb" {
|
|||
| [group_configs](variables.tf#L89) | Optional unmanaged groups to create. Can be referenced in backends via outputs. | <code title="map(object({ zone = string instances = optional(list(string)) named_ports = optional(map(number), {}) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [health_check](variables.tf#L100) | Name of existing health check to use, disables auto-created health check. | <code>string</code> | | <code>null</code> |
|
||||
| [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. | <code title="object({ check_interval_sec = optional(number) description = optional(string, "Terraform managed.") enable_logging = optional(bool, false) healthy_threshold = optional(number) timeout_sec = optional(number) unhealthy_threshold = optional(number) grpc = optional(object({ port = optional(number) port_name = optional(string) port_specification = optional(string) # USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT service_name = optional(string) })) http = optional(object({ host = optional(string) port = optional(number) port_name = optional(string) port_specification = optional(string) # USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT proxy_header = optional(string) request_path = optional(string) response = optional(string) })) http2 = optional(object({ host = optional(string) port = optional(number) port_name = optional(string) port_specification = optional(string) # USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT proxy_header = optional(string) request_path = optional(string) response = optional(string) })) https = optional(object({ host = optional(string) port = optional(number) port_name = optional(string) port_specification = optional(string) # USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT proxy_header = optional(string) request_path = optional(string) response = optional(string) })) tcp = optional(object({ port = optional(number) port_name = optional(string) port_specification = optional(string) # USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT proxy_header = optional(string) request = optional(string) response = optional(string) })) ssl = optional(object({ port = optional(number) port_name = optional(string) port_specification = optional(string) # USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT proxy_header = optional(string) request = optional(string) response = optional(string) })) })">object({…})</code> | | <code title="{ tcp = { port_specification = "USE_SERVING_PORT" } }">{…}</code> |
|
||||
| [labels](variables.tf#L180) | Labels set on resources. | <code>map(string)</code> | | <code>{}</code> |
|
||||
| [ports](variables.tf#L191) | Comma-separated ports, leave null to use all ports. | <code>list(string)</code> | | <code>null</code> |
|
||||
| [protocol](variables.tf#L202) | IP protocol used, defaults to TCP. UDP or L3_DEFAULT can also be used. | <code>string</code> | | <code>"TCP"</code> |
|
||||
| [labels](variables.tf#L183) | Labels set on resources. | <code>map(string)</code> | | <code>{}</code> |
|
||||
| [ports](variables.tf#L194) | Comma-separated ports, leave null to use all ports. | <code>list(string)</code> | | <code>null</code> |
|
||||
| [protocol](variables.tf#L205) | IP protocol used, defaults to TCP. UDP or L3_DEFAULT can also be used. | <code>string</code> | | <code>"TCP"</code> |
|
||||
|
||||
## 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. | |
|
||||
|
||||
<!-- END TFDOC -->
|
||||
|
|
|
@ -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."
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue