net-lb-app-* support any ports now

This commit is contained in:
Wiktor Niesiobędzki
2025-03-20 10:11:09 +00:00
committed by Wiktor Niesiobędzki
parent 70a330aff6
commit 256ed8dc42
9 changed files with 46 additions and 39 deletions

File diff suppressed because one or more lines are too long

View File

@@ -150,9 +150,13 @@ variable "network_tier_standard" {
}
variable "ports" {
description = "Optional ports for HTTP load balancer, valid ports are 80 and 8080."
description = "Optional ports for HTTP load balancer."
type = list(string)
default = null
validation {
condition = length(coalesce(var.ports, [])) <= 1
error_message = "Application Load Balancer supports at most one port per forwarding rule."
}
}
variable "project_id" {

File diff suppressed because one or more lines are too long

View File

@@ -54,7 +54,7 @@ resource "google_compute_global_forwarding_rule" "default" {
var.use_classic_version ? "EXTERNAL" : "EXTERNAL_MANAGED"
)
port_range = join(",", (
var.protocol == "HTTPS" ? [443] : coalesce(each.value.ports, [80])
coalesce(each.value.ports, var.protocol == "HTTPS" ? [443] : [80])
))
labels = var.labels
target = local.fwd_rule_target

View File

@@ -68,13 +68,9 @@ variable "forwarding_rules_config" {
validation {
condition = alltrue([
for k, v in var.forwarding_rules_config :
v.ports == null || (
var.protocol == "HTTPS" && alltrue([
for p in coalesce(v.ports, []) : contains([80, 8080], p)
])
)
v.ports == null || (length(coalesce(v.ports, [])) <= 1)
])
error_message = "Ports can only be configured when using HTTP. Valid HTTP ports are 80 and 8080."
error_message = "Application Load Balancer supports at most one port per forwarding rule."
}
}

File diff suppressed because one or more lines are too long

View File

@@ -127,9 +127,13 @@ variable "neg_configs" {
}
variable "ports" {
description = "Optional ports for HTTP load balancer, valid ports are 80 and 8080."
description = "Optional ports for HTTP load balancer."
type = list(string)
default = null
validation {
condition = length(coalesce(var.ports, [])) <= 1
error_message = "Application Load Balancer supports at most one port per forwarding rule."
}
}
variable "project_id" {

File diff suppressed because one or more lines are too long

View File

@@ -152,9 +152,13 @@ variable "network_tier_premium" {
}
variable "ports" {
description = "Optional ports for HTTP load balancer, valid ports are 80 and 8080."
description = "Optional ports for HTTP load balancer."
type = list(string)
default = null
validation {
condition = length(coalesce(var.ports, [])) <= 1
error_message = "Application Load Balancer supports at most one port per forwarding rule."
}
}
variable "project_id" {