From 2b800e74304314f764a2454408c7d7e4e27f389f Mon Sep 17 00:00:00 2001 From: Marcin Parafiniuk Date: Tue, 10 Dec 2024 15:22:30 +0100 Subject: [PATCH] qos rules order --- README.md | 1 + meraki_switches.tf | 25 ++++++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4284515..ab19bdc 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,7 @@ module "meraki" { | [meraki_switch_port.devices_switch_port](https://registry.terraform.io/providers/CiscoDevNet/meraki/0.1.3/docs/resources/switch_port) | resource | | [meraki_switch_port_schedule.net_switch_port_schedules](https://registry.terraform.io/providers/CiscoDevNet/meraki/0.1.3/docs/resources/switch_port_schedule) | resource | | [meraki_switch_qos_rule.net_switch_qos_rule](https://registry.terraform.io/providers/CiscoDevNet/meraki/0.1.3/docs/resources/switch_qos_rule) | resource | +| [meraki_switch_qos_rule_order.net_switch_qos_rule_order](https://registry.terraform.io/providers/CiscoDevNet/meraki/0.1.3/docs/resources/switch_qos_rule_order) | resource | | [meraki_switch_routing_interface.devices_switch_routing_interface](https://registry.terraform.io/providers/CiscoDevNet/meraki/0.1.3/docs/resources/switch_routing_interface) | resource | | [meraki_switch_routing_interface_dhcp.devices_switch_routing_interfaces_dhcp](https://registry.terraform.io/providers/CiscoDevNet/meraki/0.1.3/docs/resources/switch_routing_interface_dhcp) | resource | | [meraki_switch_routing_multicast.net_switch_routing_multicast](https://registry.terraform.io/providers/CiscoDevNet/meraki/0.1.3/docs/resources/switch_routing_multicast) | resource | diff --git a/meraki_switches.tf b/meraki_switches.tf index 393ce4c..d538bca 100644 --- a/meraki_switches.tf +++ b/meraki_switches.tf @@ -285,8 +285,8 @@ locals { for network in try(organization.networks, []) : [ for switch_qos_rule in try(network.switch_qos_rules, []) : { network_id = meraki_network.network["${organization.name}/${network.name}"].id - - data = try(switch_qos_rule, null) + key = "${organization.name}/${network.name}/qos_rules/${switch_qos_rule.qos_rule_name}" + data = try(switch_qos_rule, null) } if try(network.switch_qos_rules, null) != null ] if try(organization.networks, null) != null ] if try(domain.organizations, null) != null @@ -295,7 +295,7 @@ locals { } resource "meraki_switch_qos_rule" "net_switch_qos_rule" { - for_each = { for i, v in local.networks_switch_qos_rules : i => v } + for_each = { for i, v in local.networks_switch_qos_rules : v.key => v } network_id = each.value.network_id vlan = try(each.value.data.vlan, local.defaults.meraki.networks.networks_switch_qos_rules.vlan, null) @@ -310,6 +310,25 @@ resource "meraki_switch_qos_rule" "net_switch_qos_rule" { } +locals { + networks_switch_qos_rules_orders = flatten([ + + for domain in try(local.meraki.domains, []) : [ + for organization in try(domain.organizations, []) : [ + for network in try(organization.networks, []) : { + network_id = meraki_network.network["${organization.name}/${network.name}"].id + rule_ids = [for r in network.switch_qos_rules : meraki_switch_qos_rule.net_switch_qos_rule["${organization.name}/${network.name}/qos_rules/${r.qos_rule_name}"].id] + } if try(network.switch_qos_rules, null) != null + ] if try(domain.organizations, null) != null + ] if try(local.meraki.domains, null) != null + ]) +} + +resource "meraki_switch_qos_rule_order" "net_switch_qos_rule_order" { + for_each = { for i, v in local.networks_switch_qos_rules_orders : i => v } + network_id = each.value.network_id + rule_ids = each.value.rule_ids +} locals { networks_switch_routing_multicast = flatten([