Skip to content

Commit

Permalink
feat: Add support for optional health check fields
Browse files Browse the repository at this point in the history
Add support for all optional health check fields for different checks
  • Loading branch information
ps-occrp committed Aug 12, 2023
1 parent cc5e3c3 commit 8c9b306
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 83 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ module "gce-lb-http" {
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| address | Existing IPv4 address to use (the actual IP address value) | `string` | `null` | no |
| backends | Map backend indices to list of backend maps. | <pre>map(object({<br> port = optional(number)<br> protocol = optional(string)<br> port_name = optional(string)<br> description = optional(string)<br> enable_cdn = optional(bool)<br> compression_mode = optional(string)<br> security_policy = optional(string, null)<br> edge_security_policy = optional(string, null)<br> custom_request_headers = optional(list(string))<br> custom_response_headers = optional(list(string))<br><br> timeout_sec = optional(number)<br> connection_draining_timeout_sec = optional(number)<br> session_affinity = optional(string)<br> affinity_cookie_ttl_sec = optional(number)<br><br> health_check = object({<br> check_interval_sec = optional(number)<br> timeout_sec = optional(number)<br> healthy_threshold = optional(number)<br> unhealthy_threshold = optional(number)<br> request_path = optional(string)<br> port = optional(number)<br> host = optional(string)<br> logging = optional(bool)<br> })<br><br> log_config = object({<br> enable = optional(bool)<br> sample_rate = optional(number)<br> })<br><br> groups = list(object({<br> group = string<br><br> balancing_mode = optional(string)<br> capacity_scaler = optional(number)<br> description = optional(string)<br> max_connections = optional(number)<br> max_connections_per_instance = optional(number)<br> max_connections_per_endpoint = optional(number)<br> max_rate = optional(number)<br> max_rate_per_instance = optional(number)<br> max_rate_per_endpoint = optional(number)<br> max_utilization = optional(number)<br> }))<br> iap_config = object({<br> enable = bool<br> oauth2_client_id = optional(string)<br> oauth2_client_secret = optional(string)<br> })<br> cdn_policy = optional(object({<br> cache_mode = optional(string)<br> signed_url_cache_max_age_sec = optional(string)<br> default_ttl = optional(number)<br> max_ttl = optional(number)<br> client_ttl = optional(number)<br> negative_caching = optional(bool)<br> negative_caching_policy = optional(object({<br> code = optional(number)<br> ttl = optional(number)<br> }))<br> serve_while_stale = optional(number)<br> cache_key_policy = optional(object({<br> include_host = optional(bool)<br> include_protocol = optional(bool)<br> include_query_string = optional(bool)<br> query_string_blacklist = optional(list(string))<br> query_string_whitelist = optional(list(string))<br> include_http_headers = optional(list(string))<br> include_named_cookies = optional(list(string))<br> }))<br> }))<br> }))</pre> | n/a | yes |
| backends | Map backend indices to list of backend maps. | <pre>map(object({<br> port = optional(number)<br> protocol = optional(string)<br> port_name = optional(string)<br> description = optional(string)<br> enable_cdn = optional(bool)<br> compression_mode = optional(string)<br> security_policy = optional(string, null)<br> edge_security_policy = optional(string, null)<br> custom_request_headers = optional(list(string))<br> custom_response_headers = optional(list(string))<br><br> timeout_sec = optional(number)<br> connection_draining_timeout_sec = optional(number)<br> session_affinity = optional(string)<br> affinity_cookie_ttl_sec = optional(number)<br><br> health_check = object({<br> host = optional(string)<br> request_path = optional(string)<br> request = optional(string)<br> response = optional(string)<br> port = optional(number)<br> port_name = optional(string)<br> proxy_header = optional(string)<br> port_specification = optional(string)<br> check_interval_sec = optional(number)<br> timeout_sec = optional(number)<br> healthy_threshold = optional(number)<br> unhealthy_threshold = optional(number)<br> logging = optional(bool)<br> })<br><br> log_config = object({<br> enable = optional(bool)<br> sample_rate = optional(number)<br> })<br><br> groups = list(object({<br> group = string<br><br> balancing_mode = optional(string)<br> capacity_scaler = optional(number)<br> description = optional(string)<br> max_connections = optional(number)<br> max_connections_per_instance = optional(number)<br> max_connections_per_endpoint = optional(number)<br> max_rate = optional(number)<br> max_rate_per_instance = optional(number)<br> max_rate_per_endpoint = optional(number)<br> max_utilization = optional(number)<br> }))<br> iap_config = object({<br> enable = bool<br> oauth2_client_id = optional(string)<br> oauth2_client_secret = optional(string)<br> })<br> cdn_policy = optional(object({<br> cache_mode = optional(string)<br> signed_url_cache_max_age_sec = optional(string)<br> default_ttl = optional(number)<br> max_ttl = optional(number)<br> client_ttl = optional(number)<br> negative_caching = optional(bool)<br> negative_caching_policy = optional(object({<br> code = optional(number)<br> ttl = optional(number)<br> }))<br> serve_while_stale = optional(number)<br> cache_key_policy = optional(object({<br> include_host = optional(bool)<br> include_protocol = optional(bool)<br> include_query_string = optional(bool)<br> query_string_blacklist = optional(list(string))<br> query_string_whitelist = optional(list(string))<br> include_http_headers = optional(list(string))<br> include_named_cookies = optional(list(string))<br> }))<br> }))<br> }))</pre> | n/a | yes |
| certificate | Content of the SSL certificate. Required if `ssl` is `true` and `ssl_certificates` is empty. | `string` | `null` | no |
| certificate\_map | Certificate Map ID in format projects/{project}/locations/global/certificateMaps/{name}. Identifies a certificate map associated with the given target proxy | `string` | `null` | no |
| create\_address | Create a new global IPv4 address | `bool` | `true` | no |
Expand Down
72 changes: 48 additions & 24 deletions autogen/main.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -317,70 +317,94 @@ resource "google_compute_health_check" "default" {
dynamic "http_health_check" {
for_each = each.value["protocol"] == "HTTP" ? [
{
host = lookup(each.value["health_check"], "host", null)
request_path = lookup(each.value["health_check"], "request_path", null)
port = lookup(each.value["health_check"], "port", null)
host = lookup(each.value["health_check"], "host", null)
request_path = lookup(each.value["health_check"], "request_path", null)
response = lookup(each.value["health_check"], "response", null)
port = lookup(each.value["health_check"], "port", null)
port_name = lookup(each.value["health_check"], "port_name", null)
proxy_header = lookup(each.value["health_check"], "proxy_header", null)
port_specification = lookup(each.value["health_check"], "port_specification", null)
}
] : []

content {
host = lookup(http_health_check.value, "host", null)
request_path = lookup(http_health_check.value, "request_path", null)
port = lookup(http_health_check.value, "port", null)
host = lookup(http_health_check.value, "host", null)
request_path = lookup(http_health_check.value, "request_path", null)
response = lookup(http_health_check.value, "response", null)
port = lookup(http_health_check.value, "port", null)
port_name = lookup(http_health_check.value, "port_name", null)
proxy_header = lookup(http_health_check.value, "proxy_header", null)
port_specification = lookup(http_health_check.value, "port_specification", null)
}
}

dynamic "https_health_check" {
for_each = each.value["protocol"] == "HTTPS" ? [
{
host = lookup(each.value["health_check"], "host", null)
request_path = lookup(each.value["health_check"], "request_path", null)
port = lookup(each.value["health_check"], "port", null)
host = lookup(each.value["health_check"], "host", null)
request_path = lookup(each.value["health_check"], "request_path", null)
response = lookup(each.value["health_check"], "response", null)
port = lookup(each.value["health_check"], "port", null)
port_name = lookup(each.value["health_check"], "port_name", null)
proxy_header = lookup(each.value["health_check"], "proxy_header", null)
port_specification = lookup(each.value["health_check"], "port_specification", null)
}
] : []

content {
host = lookup(https_health_check.value, "host", null)
request_path = lookup(https_health_check.value, "request_path", null)
port = lookup(https_health_check.value, "port", null)
host = lookup(https_health_check.value, "host", null)
request_path = lookup(https_health_check.value, "request_path", null)
response = lookup(https_health_check.value, "response", null)
port = lookup(https_health_check.value, "port", null)
port_name = lookup(https_health_check.value, "port_name", null)
proxy_header = lookup(https_health_check.value, "proxy_header", null)
port_specification = lookup(https_health_check.value, "port_specification", null)
}
}

dynamic "http2_health_check" {
for_each = each.value["protocol"] == "HTTP2" ? [
{
host = lookup(each.value["health_check"], "host", null)
request_path = lookup(each.value["health_check"], "request_path", null)
port = lookup(each.value["health_check"], "port", null)
host = lookup(each.value["health_check"], "host", null)
request_path = lookup(each.value["health_check"], "request_path", null)
response = lookup(each.value["health_check"], "response", null)
port = lookup(each.value["health_check"], "port", null)
port_name = lookup(each.value["health_check"], "port_name", null)
proxy_header = lookup(each.value["health_check"], "proxy_header", null)
port_specification = lookup(each.value["health_check"], "port_specification", null)
}
] : []

content {
host = lookup(http2_health_check.value, "host", null)
request_path = lookup(http2_health_check.value, "request_path", null)
port = lookup(http2_health_check.value, "port", null)
host = lookup(http2_health_check.value, "host", null)
request_path = lookup(http2_health_check.value, "request_path", null)
response = lookup(http2_health_check.value, "response", null)
port = lookup(http2_health_check.value, "port", null)
port_name = lookup(http2_health_check.value, "port_name", null)
proxy_header = lookup(http2_health_check.value, "proxy_header", null)
port_specification = lookup(http2_health_check.value, "port_specification", null)
}
}

dynamic "tcp_health_check" {
for_each = each.value["protocol"] == "TCP" ? [
{
request = lookup(each.value["health_check"], "request", null)
response = lookup(each.value["health_check"], "response", null)
port = lookup(each.value["health_check"], "port", null)
port_name = lookup(each.value["health_check"], "port_name", null)
port_specification = lookup(each.value["health_check"], "port_specification", null)
request = lookup(each.value["health_check"], "request", null)
proxy_header = lookup(each.value["health_check"], "proxy_header", null)
response = lookup(each.value["health_check"], "response", null)
port_specification = lookup(each.value["health_check"], "port_specification", null)
}
] : []

content {
request = lookup(tcp_health_check.value, "request", null)
response = lookup(tcp_health_check.value, "response", null)
port = lookup(tcp_health_check.value, "port", null)
port_name = lookup(tcp_health_check.value, "port_name", null)
port_specification = lookup(tcp_health_check.value, "port_specification", null)
request = lookup(tcp_health_check.value, "request", null)
proxy_header = lookup(tcp_health_check.value, "proxy_header", null)
response = lookup(tcp_health_check.value, "response", null)
port_specification = lookup(tcp_health_check.value, "port_specification", null)
}
}
}
Expand Down
11 changes: 8 additions & 3 deletions autogen/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,18 @@ variable "backends" {
{% if not serverless %}
{# Serverless NEGs don't support health checks #}
health_check = object({
host = optional(string)
request_path = optional(string)
request = optional(string)
response = optional(string)
port = optional(number)
port_name = optional(string)
proxy_header = optional(string)
port_specification = optional(string)
check_interval_sec = optional(number)
timeout_sec = optional(number)
healthy_threshold = optional(number)
unhealthy_threshold = optional(number)
request_path = optional(string)
port = optional(number)
host = optional(string)
logging = optional(bool)
})
{% endif %}
Expand Down
Loading

0 comments on commit 8c9b306

Please sign in to comment.