Hi
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 = var.lb-cert.cert-exist == true ? var.lb-cert.certificate-arn : acm.acm_certificate_arn
ssl_policy = var.lb-cert.cert-exist == true ? var.lb-cert.security-policy : "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
Is there a possibility to create another object when list from module.acm is empty ?
Thanks for help