Skip to content

Cloud run V2 - multi containers exposed port #302

@sylvain-actual

Description

@sylvain-actual

Hello,

I am trying to setup a multiple container cloud run, but I am getting this error :

Error creating Service: googleapi: Error 400: template.containers: Revision template should contain exactly one container with an exposed port.

My setup :

module "multi" {
  source  = "GoogleCloudPlatform/cloud-run/google//modules/v2"
  version = "0.16.3"

  project_id      = "XXXX"
  service_name    = "hello-world"
  location        = "europe-west9"

  containers      = [
    {
      container_image = "nginx:latest"
      container_name  = "nginx"
      ports = {
        name           = "http1"
        container_port = "80"
      }
    },
    {
      container_image = "us-docker.pkg.dev/cloudrun/container/hello"
      container_name  = "hello"
    },
  ]
}

So maybe I am missing someting, of this local is not working as expected :

  ingress_container = try(
    [for container in var.containers : container if length(try(container.ports, {})) > 0][0],
    null
  )

This one should work :

containers_with_ports = [for c in var.containers : c if lookup(c, "port", null) != null]

Thx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions