Skip to content

Commit 1e0521c

Browse files
atrullq2w
authored andcommitted
fix[sidecars]: Permit optional ports for sidecars.
1 parent 84fc0cb commit 1e0521c

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

modules/v2/main.tf

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,20 @@ resource "google_cloud_run_v2_service" "main" {
158158
args = containers.value.container_args
159159
working_dir = containers.value.working_dir
160160
depends_on = containers.value.depends_on_container
161+
161162
dynamic "ports" {
162-
for_each = lookup(containers.value, "ports", {}) != {} ? [containers.value.ports] : []
163+
for_each = try(
164+
(
165+
containers.value.ports != null &&
166+
containers.value.ports.container_port != null &&
167+
containers.value.ports.container_port > 0 &&
168+
containers.value.ports.container_port < 65536
169+
) ? [containers.value.ports] : [],
170+
[]
171+
)
163172
content {
164-
name = ports.value["name"]
165-
container_port = ports.value["container_port"]
173+
name = try(ports.value.name, null)
174+
container_port = ports.value.container_port
166175
}
167176
}
168177

modules/v2/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ variable "containers" {
5555
mount_path = string
5656
})), [])
5757
ports = optional(object({
58-
name = optional(string, "http1")
59-
container_port = optional(number, 8080)
58+
name = optional(string)
59+
container_port = optional(number)
6060
}), {})
6161
resources = optional(object({
6262
limits = optional(object({

0 commit comments

Comments
 (0)