From f16c4a1e0b109446b7a84cd6cc3eba7e5d409c39 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Wed, 24 Apr 2024 15:54:24 +0100 Subject: [PATCH] Revert "Use `coalescelist` instead" The ternary operator uses short-circuiting, whereas `coalescelist` always evaluates `module.vpc[0].private_subnets` and fails if `module.vpc[0]` doesn't exist. --- ecs-cluster/keycloak.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ecs-cluster/keycloak.tf b/ecs-cluster/keycloak.tf index 280d70f..817b35d 100644 --- a/ecs-cluster/keycloak.tf +++ b/ecs-cluster/keycloak.tf @@ -5,8 +5,8 @@ locals { keycloak-hostname = var.keycloak-hostname == "" ? aws_lb.keycloak.dns_name : var.keycloak-hostname vpc_id = var.vpc-id == "" ? module.vpc[0].vpc_id : var.vpc-id - public_subnets = coalescelist(var.public-subnets, module.vpc[0].public_subnets) - private_subnets = coalescelist(var.private-subnets, module.vpc[0].private_subnets) + public_subnets = length(var.public-subnets) == 0 ? module.vpc[0].public_subnets : var.public-subnets + private_subnets = length(var.private-subnets) == 0 ? module.vpc[0].private_subnets : var.private-subnets } resource "random_password" "db-password" {