Added backend preference to global application load balancers (#3139)
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -78,6 +78,7 @@ resource "google_compute_backend_service" "default" {
|
||||
for_each = { for b in coalesce(each.value.backends, []) : b.backend => b }
|
||||
content {
|
||||
group = lookup(local.group_ids, backend.key, backend.key)
|
||||
preference = backend.value.preference
|
||||
balancing_mode = backend.value.balancing_mode # UTILIZATION, RATE
|
||||
capacity_scaler = backend.value.capacity_scaler
|
||||
description = backend.value.description
|
||||
|
||||
@@ -37,6 +37,7 @@ variable "backend_service_configs" {
|
||||
backends = list(object({
|
||||
# group renamed to backend
|
||||
backend = string
|
||||
preference = optional(string, "DEFAULT")
|
||||
balancing_mode = optional(string, "UTILIZATION")
|
||||
capacity_scaler = optional(number, 1)
|
||||
description = optional(string, "Terraform managed.")
|
||||
@@ -163,6 +164,15 @@ variable "backend_service_configs" {
|
||||
]))
|
||||
error_message = "When specified, balancing mode needs to be 'RATE' or 'UTILIZATION'."
|
||||
}
|
||||
validation {
|
||||
condition = alltrue(flatten([
|
||||
for backend_service in values(var.backend_service_configs) : [
|
||||
for backend in backend_service.backends : contains(
|
||||
["DEFAULT", "PREFERRED"], coalesce(backend.preference, "DEFAULT")
|
||||
)]
|
||||
]))
|
||||
error_message = "When specified, balancing mode needs to be 'DEFAULT' or 'PREFERRED'."
|
||||
}
|
||||
validation {
|
||||
condition = alltrue([
|
||||
for backend_service in values(var.backend_service_configs) :
|
||||
|
||||
Reference in New Issue
Block a user