From a733bfe6c5f8998d31358184f3759ff6d8f406f3 Mon Sep 17 00:00:00 2001 From: Israel Herraiz Date: Fri, 30 Dec 2022 11:27:37 +0100 Subject: [PATCH] Use map for local clusters variable --- modules/bigtable-instance/main.tf | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/modules/bigtable-instance/main.tf b/modules/bigtable-instance/main.tf index c9ed9094a..3a00eab89 100644 --- a/modules/bigtable-instance/main.tf +++ b/modules/bigtable-instance/main.tf @@ -25,15 +25,14 @@ locals { ] ]) - clusters_autoscaling = flatten([ - for cluster, obj in var.clusters : [{ - cluster_id = cluster - zone = obj.zone - storage_type = obj.storage_type - num_nodes = obj.autoscaling == null && var.default_autoscaling == null ? obj.num_nodes : null - autoscaling = obj.autoscaling == null ? var.default_autoscaling : obj.autoscaling - }] - ]) + clusters_autoscaling = { + for cluster_id, cluster in var.clusters : cluster_id => { + zone = cluster.zone + storage_type = cluster.storage_type + num_nodes = cluster.autoscaling == null && var.default_autoscaling == null ? cluster.num_nodes : null + autoscaling = cluster.autoscaling == null ? var.default_autoscaling : cluster.autoscaling + } + } } resource "google_bigtable_instance" "default" { @@ -45,9 +44,9 @@ resource "google_bigtable_instance" "default" { deletion_protection = var.deletion_protection dynamic "cluster" { - for_each = { for k, v in local.clusters_autoscaling : k => v } + for_each = local.clusters_autoscaling content { - cluster_id = cluster.value.cluster_id + cluster_id = cluster.key zone = cluster.value.zone storage_type = cluster.value.storage_type num_nodes = cluster.value.num_nodes