Fixed problem with backend preference, changed it to boolean. Backend preference can only be PREFERRED or null
This commit is contained in:
committed by
Wiktor Niesiobędzki
parent
e3b73b8867
commit
42641397e3
File diff suppressed because one or more lines are too long
@@ -78,7 +78,7 @@ resource "google_compute_backend_service" "default" {
|
|||||||
for_each = { for b in coalesce(each.value.backends, []) : b.backend => b }
|
for_each = { for b in coalesce(each.value.backends, []) : b.backend => b }
|
||||||
content {
|
content {
|
||||||
group = lookup(local.group_ids, backend.key, backend.key)
|
group = lookup(local.group_ids, backend.key, backend.key)
|
||||||
preference = backend.value.preference
|
preference = backend.value.preferred ? "PREFERRED" : null
|
||||||
balancing_mode = backend.value.balancing_mode # UTILIZATION, RATE
|
balancing_mode = backend.value.balancing_mode # UTILIZATION, RATE
|
||||||
capacity_scaler = backend.value.capacity_scaler
|
capacity_scaler = backend.value.capacity_scaler
|
||||||
description = backend.value.description
|
description = backend.value.description
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ variable "backend_service_configs" {
|
|||||||
backends = list(object({
|
backends = list(object({
|
||||||
# group renamed to backend
|
# group renamed to backend
|
||||||
backend = string
|
backend = string
|
||||||
preference = optional(string, "DEFAULT")
|
preferred = optional(bool, false)
|
||||||
balancing_mode = optional(string, "UTILIZATION")
|
balancing_mode = optional(string, "UTILIZATION")
|
||||||
capacity_scaler = optional(number, 1)
|
capacity_scaler = optional(number, 1)
|
||||||
description = optional(string, "Terraform managed.")
|
description = optional(string, "Terraform managed.")
|
||||||
@@ -164,15 +164,6 @@ variable "backend_service_configs" {
|
|||||||
]))
|
]))
|
||||||
error_message = "When specified, balancing mode needs to be 'RATE' or 'UTILIZATION'."
|
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 {
|
validation {
|
||||||
condition = alltrue([
|
condition = alltrue([
|
||||||
for backend_service in values(var.backend_service_configs) :
|
for backend_service in values(var.backend_service_configs) :
|
||||||
|
|||||||
Reference in New Issue
Block a user