From b3b2e9a262c3b717f7f7696f931a0f1e1f4067a1 Mon Sep 17 00:00:00 2001 From: Marcin Parafiniuk Date: Wed, 11 Dec 2024 15:25:35 +0100 Subject: [PATCH] wireless ssid number --- meraki_wireless.tf | 40 +++++++++++++--------------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/meraki_wireless.tf b/meraki_wireless.tf index 0adec52..e2caab9 100644 --- a/meraki_wireless.tf +++ b/meraki_wireless.tf @@ -143,29 +143,15 @@ resource "meraki_wireless_settings" "net_wireless_settings" { } # Apply the Wireless SSIDs locals { - wireless_ssids_numbers_list = flatten([ - - for domain in try(local.meraki.domains, []) : [ - for organization in try(domain.organizations, []) : [ - for network in try(organization.networks, []) : [ - for i, wireless_ssid in try(network.wireless_ssids, []) : { - key = format("${organization.name}/${network.name}/wireless_ssid/${wireless_ssid.name}") - number = i - } if try(network.wireless_ssids, null) != null - ] if try(organization.networks, null) != null - ] if try(domain.organizations, null) != null - ] if try(local.meraki.domains, null) != null - ]) - wireless_ssids_map = { for w in local.wireless_ssids_numbers_list : w.key => w.number } networks_wireless_ssids = flatten([ for domain in try(local.meraki.domains, []) : [ for organization in try(domain.organizations, []) : [ for network in try(organization.networks, []) : [ - for i, wireless_ssid in try(network.wireless_ssids, []) : { + for wireless_ssid in try(network.wireless_ssids, []) : { network_id = meraki_network.network["${organization.name}/${network.name}"].id - number = i data = try(wireless_ssid, null) + key = "${organization.name}/${network.name}/ssids/${wireless_ssid.name}" } if try(network.wireless_ssids, null) != null ] if try(organization.networks, null) != null ] if try(domain.organizations, null) != null @@ -174,9 +160,9 @@ locals { } resource "meraki_wireless_ssid" "net_wireless_ssids" { - for_each = { for i, v in local.networks_wireless_ssids : i => v } + for_each = { for v in local.networks_wireless_ssids : v.key => v } network_id = each.value.network_id - number = each.value.number + number = each.value.data.number name = try(each.value.data.name, local.defaults.meraki.networks.networks_wireless_ssids.name, null) enabled = try(each.value.data.enabled, local.defaults.meraki.networks.networks_wireless_ssids.enabled, null) @@ -266,7 +252,7 @@ locals { for wireless_ssid in try(network.wireless_ssids, []) : { network_id = meraki_network.network["${organization.name}/${network.name}"].id eap_override = try(wireless_ssid.eap_override, null) - number = local.wireless_ssids_map["${organization.name}/${network.name}/wireless_ssid/${wireless_ssid.name}"] + number = meraki_wireless_ssid.net_wireless_ssids["${organization.name}/${network.name}/ssids/${wireless_ssid.name}"].number } if try(wireless_ssid.eap_override, null) != null ] if try(organization.networks, null) != null ] if try(domain.organizations, null) != null @@ -296,7 +282,7 @@ locals { for network in try(organization.networks, []) : [ for wireless_ssid in try(network.wireless_ssids, []) : { network_id = meraki_network.network["${organization.name}/${network.name}"].id - number = local.wireless_ssids_map["${organization.name}/${network.name}/wireless_ssid/${wireless_ssid.name}"] + number = meraki_wireless_ssid.net_wireless_ssids["${organization.name}/${network.name}/ssids/${wireless_ssid.name}"].number data = try(wireless_ssid.device_type_group_policies, null) } if try(wireless_ssid.device_type_group_policies, null) != null ] if try(organization.networks, null) != null @@ -327,7 +313,7 @@ locals { for network in try(organization.networks, []) : [ for wireless_ssid in try(network.wireless_ssids, []) : { network_id = meraki_network.network["${organization.name}/${network.name}"].id - number = local.wireless_ssids_map["${organization.name}/${network.name}/wireless_ssid/${wireless_ssid.name}"] + number = meraki_wireless_ssid.net_wireless_ssids["${organization.name}/${network.name}/ssids/${wireless_ssid.name}"].number data = try(wireless_ssid.firewall_l3_firewall_rules, null) } if try(wireless_ssid.firewall_l3_firewall_rules, null) != null ] if try(organization.networks, null) != null @@ -357,7 +343,7 @@ locals { for network in try(organization.networks, []) : [ for wireless_ssid in try(network.wireless_ssids, []) : { network_id = meraki_network.network["${organization.name}/${network.name}"].id - number = local.wireless_ssids_map["${organization.name}/${network.name}/wireless_ssid/${wireless_ssid.name}"] + number = meraki_wireless_ssid.net_wireless_ssids["${organization.name}/${network.name}/ssids/${wireless_ssid.name}"].number data = try(wireless_ssid.hotspot20, null) } if try(wireless_ssid.hotspot20, null) != null ] if try(organization.networks, null) != null @@ -394,7 +380,7 @@ locals { for wireless_ssid in try(network.wireless_ssids, []) : [ for identity_psk in try(wireless_ssid.identity_psks, []) : { network_id = meraki_network.network["${organization.name}/${network.name}"].id - number = local.wireless_ssids_map["${organization.name}/${network.name}/wireless_ssid/${wireless_ssid.name}"] + number = meraki_wireless_ssid.net_wireless_ssids["${organization.name}/${network.name}/ssids/${wireless_ssid.name}"].number data = try(identity_psk, null) } if try(wireless_ssid.identity_psks, null) != null ] if try(network.wireless_ssids, null) != null @@ -427,7 +413,7 @@ locals { for network in try(organization.networks, []) : [ for wireless_ssid in try(network.wireless_ssids, []) : { network_id = meraki_network.network["${organization.name}/${network.name}"].id - number = local.wireless_ssids_map["${organization.name}/${network.name}/wireless_ssid/${wireless_ssid.name}"] + number = meraki_wireless_ssid.net_wireless_ssids["${organization.name}/${network.name}/ssids/${wireless_ssid.name}"].number data = try(wireless_ssid.schedules, null) } if try(wireless_ssid.schedules, null) != null ] if try(organization.networks, null) != null @@ -457,7 +443,7 @@ locals { for network in try(organization.networks, []) : [ for wireless_ssid in try(network.wireless_ssids, []) : { network_id = meraki_network.network["${organization.name}/${network.name}"].id - number = local.wireless_ssids_map["${organization.name}/${network.name}/wireless_ssid/${wireless_ssid.name}"] + number = meraki_wireless_ssid.net_wireless_ssids["${organization.name}/${network.name}/ssids/${wireless_ssid.name}"].number data = try(wireless_ssid.splash_settings, null) } if try(wireless_ssid.splash_settings, null) != null ] if try(organization.networks, null) != null @@ -516,7 +502,7 @@ locals { for network in try(organization.networks, []) : [ for wireless_ssid in try(network.wireless_ssids, []) : { network_id = meraki_network.network["${organization.name}/${network.name}"].id - number = local.wireless_ssids_map["${organization.name}/${network.name}/wireless_ssid/${wireless_ssid.name}"] + number = meraki_wireless_ssid.net_wireless_ssids["${organization.name}/${network.name}/ssids/${wireless_ssid.name}"].number data = try(wireless_ssid.traffic_shaping_rules, null) } if try(wireless_ssid.traffic_shaping_rules, null) != null ] if try(organization.networks, null) != null @@ -547,7 +533,7 @@ locals { for network in try(organization.networks, []) : [ for wireless_ssid in try(network.wireless_ssids, []) : { network_id = meraki_network.network["${organization.name}/${network.name}"].id - number = local.wireless_ssids_map["${organization.name}/${network.name}/wireless_ssid/${wireless_ssid.name}"] + number = meraki_wireless_ssid.net_wireless_ssids["${organization.name}/${network.name}/ssids/${wireless_ssid.name}"].number data = try(wireless_ssid.bonjour_forwarding, null) } if try(wireless_ssid.bonjour_forwarding, null) != null ] if try(organization.networks, null) != null