From e0d59eb1662ffba4b417aa5374c6bf81dd89a70f Mon Sep 17 00:00:00 2001 From: Rob Gil Date: Thu, 23 Jan 2020 20:22:53 -0500 Subject: [PATCH] Finally fixes subnet list output This finally fixes the output coming from the vpc module so that it returns a full list of subnets. Now they can be referenced just like the redis module is using in this commit. --- terraform/modules/vpc/outputs.tf | 8 +++++++- terraform/providers/dev/redis.tf | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/terraform/modules/vpc/outputs.tf b/terraform/modules/vpc/outputs.tf index eedaab6c..baa32935 100644 --- a/terraform/modules/vpc/outputs.tf +++ b/terraform/modules/vpc/outputs.tf @@ -1,3 +1,9 @@ output "subnets" { - value = azurerm_subnet.subnet["private"].id #FIXME - output should be a map + value = azurerm_subnet.subnet["private"].id #FIXED: this is now legacy, use subnet_list } + +output "subnet_list" { + value = { + for k, id in azurerm_subnet.subnet : k => id + } +} \ No newline at end of file diff --git a/terraform/providers/dev/redis.tf b/terraform/providers/dev/redis.tf index 78cb4b2b..8c89dc92 100644 --- a/terraform/providers/dev/redis.tf +++ b/terraform/providers/dev/redis.tf @@ -4,7 +4,7 @@ module "redis" { environment = var.environment region = var.region name = var.name - subnet_id = module.vpc.subnets + subnet_id = module.vpc.subnet_list["redis"].id sku_name = "Premium" family = "P" }