For loop create object when list is empty

I’m writing a module for create AWS ALB.
In module I creta certs, listeners, etc.

I’m facing with following scenario:
I have already created cert and want use in https_listener object.
I use acm module and set that is empty when I want use existing cert.

In main lb modules I have following for loop:

module "lb" {
  source  = "terraform-aws-modules/alb/aws"
  version = "~> 6.0"

  https_listeners = [
    for key, acm in module.acm : {
      port            = 443
      protocol        = "HTTPS"
      certificate_arn = == true ? : acm.acm_certificate_arn
      ssl_policy      = == true ? : "ELBSecurityPolic04"
    } if (key == local.first_domain_name)

When I have generated certs by acm module everything works well, but when I have empty list https listener not created.
I looking for solution but didn’t find :frowning:

Is there a possibility to create another object when list from module.acm is empty ?

Thanks for help

Not able to test now, but you maybe just use the length function?

for idx,acm in length(module.acm) > 0 ? module.acm : var.something

…or maybe the try function.