diff --git a/modules/backend/README.md b/modules/backend/README.md index 7fd910de..27e3a21d 100644 --- a/modules/backend/README.md +++ b/modules/backend/README.md @@ -20,7 +20,8 @@ This module creates `google_compute_backend_service` resource and its dependenci | firewall\_projects | Names of the projects to create firewall rules in | `list(string)` |
[| no | | firewall\_source\_ranges | Source ranges for the global Application Load Balancer's proxies. This list should contain the `ip_cidr_range` of each GLOBAL\_MANAGED\_PROXY subnet. | `list(string)` |
"default"
]
[| no | | groups | The list of backend instance group which serves the traffic. |
"10.127.0.0/23"
]
list(object({
group = string
description = optional(string)
balancing_mode = optional(string)
capacity_scaler = optional(number)
max_connections = optional(number)
max_connections_per_instance = optional(number)
max_connections_per_endpoint = optional(number)
max_rate = optional(number)
max_rate_per_instance = optional(number)
max_rate_per_endpoint = optional(number)
max_utilization = optional(number)
})) | `[]` | no |
-| health\_check | Input for creating HttpHealthCheck or HttpsHealthCheck resource for health checking this BackendService. A health check must be specified unless the backend service uses an internet or serverless NEG as a backend. | object({
host = optional(string, null)
request_path = optional(string, null)
request = optional(string, null)
response = optional(string, null)
port = optional(number, null)
port_name = optional(string, null)
proxy_header = optional(string, null)
port_specification = optional(string, null)
protocol = optional(string, null)
check_interval_sec = optional(number, 5)
timeout_sec = optional(number, 5)
healthy_threshold = optional(number, 2)
unhealthy_threshold = optional(number, 2)
logging = optional(bool, false)
}) | `null` | no |
+| health\_check | Input for creating HttpHealthCheck or HttpsHealthCheck resource for health checking this BackendService. Either `health\_check` or `health\_check\_self\_link` must be specidied unless the backend service uses an internet or serverless NEG as a backend. | object({
host = optional(string, null)
request_path = optional(string, null)
request = optional(string, null)
response = optional(string, null)
port = optional(number, null)
port_name = optional(string, null)
proxy_header = optional(string, null)
port_specification = optional(string, null)
protocol = optional(string, null)
check_interval_sec = optional(number, 5)
timeout_sec = optional(number, 5)
healthy_threshold = optional(number, 2)
unhealthy_threshold = optional(number, 2)
logging = optional(bool, false)
}) | `null` | no |
+| health\_check\_self\_link | Self link of an existing health check. Either `health\_check` or `health\_check\_self\_link` must be specidied unless the backend service uses an internet or serverless NEG as a backend. | `string` | `null` | no |
| host\_path\_mappings | The list of host/path for which traffic could be sent to the backend service | list(object({
host = string
path = string
})) | [| no | | iap\_config | Settings for enabling Cloud Identity Aware Proxy Structure. |
{
"host": "*",
"path": "/*"
}
]
object({
enable = bool
oauth2_client_id = optional(string)
oauth2_client_secret = optional(string)
}) | {
"enable": false
} | no |
| load\_balancing\_scheme | Load balancing scheme type (EXTERNAL for classic external load balancer, EXTERNAL\_MANAGED for Envoy-based load balancer, INTERNAL\_MANAGED for internal load balancer and INTERNAL\_SELF\_MANAGED for traffic director) | `string` | `"EXTERNAL_MANAGED"` | no |
diff --git a/modules/backend/main.tf b/modules/backend/main.tf
index ebe6f035..cc1b65d8 100644
--- a/modules/backend/main.tf
+++ b/modules/backend/main.tf
@@ -44,7 +44,7 @@ resource "google_compute_backend_service" "default" {
security_policy = var.security_policy
timeout_sec = var.timeout_sec
- health_checks = var.health_check != null ? google_compute_health_check.default[*].self_link : null
+ health_checks = var.health_check != null ? google_compute_health_check.default[*].self_link : ( var.health_check_self_link != null ? [var.health_check_self_link] : [] )
dynamic "backend" {
for_each = toset(var.groups)
diff --git a/modules/backend/variables.tf b/modules/backend/variables.tf
index 0cca6482..ce025015 100644
--- a/modules/backend/variables.tf
+++ b/modules/backend/variables.tf
@@ -222,7 +222,7 @@ variable "outlier_detection" {
}
variable "health_check" {
- description = "Input for creating HttpHealthCheck or HttpsHealthCheck resource for health checking this BackendService. A health check must be specified unless the backend service uses an internet or serverless NEG as a backend."
+ description = "Input for creating HttpHealthCheck or HttpsHealthCheck resource for health checking this BackendService. Either health_check or health_check_self_link must be specidied unless the backend service uses an internet or serverless NEG as a backend."
type = object({
host = optional(string, null)
request_path = optional(string, null)
@@ -242,6 +242,12 @@ variable "health_check" {
default = null
}
+variable "health_check_self_link" {
+ description = "Self link of an existing health check. Either health_check or health_check_self_link must be specidied unless the backend service uses an internet or serverless NEG as a backend."
+ type = string
+ default = null
+}
+
variable "edge_security_policy" {
description = "The resource URL for the edge security policy to associate with the backend service"
type = string