Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions modules/v2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,20 @@ resource "google_cloud_run_v2_service" "main" {
args = containers.value.container_args
working_dir = containers.value.working_dir
depends_on = containers.value.depends_on_container

dynamic "ports" {
for_each = lookup(containers.value, "ports", {}) != {} ? [containers.value.ports] : []
for_each = try(
(
containers.value.ports != null &&
containers.value.ports.container_port != null &&
containers.value.ports.container_port > 0 &&
containers.value.ports.container_port < 65536
) ? [containers.value.ports] : [],
[]
)
content {
name = ports.value["name"]
container_port = ports.value["container_port"]
name = try(ports.value.name, null)
container_port = ports.value.container_port
}
}

Expand Down
4 changes: 2 additions & 2 deletions modules/v2/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ variable "containers" {
mount_path = string
})), [])
ports = optional(object({
name = optional(string, "http1")
container_port = optional(number, 8080)
name = optional(string)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What name for the port is used if users doesn't define name but only configures container_port

container_port = optional(number)
}), {})
resources = optional(object({
limits = optional(object({
Expand Down
Loading