From ffad0f22f6e8213a093a17b07ccdb076af53daed Mon Sep 17 00:00:00 2001
From: Jon <jonhumph@cisco.com>
Date: Mon, 10 Jun 2024 22:43:02 +0100
Subject: [PATCH] refactor: Update Meraki organization network configuration

---
 meraki_organization.tf | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/meraki_organization.tf b/meraki_organization.tf
index ee1d16c..872d408 100644
--- a/meraki_organization.tf
+++ b/meraki_organization.tf
@@ -1,21 +1,16 @@
-data "meraki_organizations" "organizations" {
+output "meraki_domains_organizations" {
+  description = "Output the value of local.meraki.domains.organizations for debugging"
+  value       = local.meraki.domains.organizations
 }
 
-locals {
-  organization_map = { for organization in data.meraki_organizations.organizations.items : organization.name => organization.id }
-  networks = flatten([
-    for org in try(local.meraki.domains.organizations, []) : [
-      for network in try(org.networks, []) : {
-        key             = format("%s/%s", org.name, network.name)
-        organization_id = local.organization_map[org.name]
-        name            = try(network.name, local.defaults.meraki.organizations.networks.name)
-        notes           = try(network.notes, local.defaults.meraki.organizations.networks.notes)
-        product_types   = try(network.product_types, local.defaults.meraki.organizations.networks.product_types)
-        tags            = try(network.tags, local.defaults.meraki.organizations.networks.tags)
-        time_zone       = try(network.timezone, local.defaults.meraki.organizations.networks.timezone)
-      }
-    ]
-  ])
+output "organization_map" {
+  description = "Output the value of local.organization_map for debugging"
+  value       = local.organization_map
+}
+
+output "networks" {
+  description = "Output the value of local.networks for debugging"
+  value       = local.networks
 }
 
 resource "meraki_networks" "networks" {