Skip to content

Commit

Permalink
refactor: Update meraki_networks.tf to use local variable for switch …
Browse files Browse the repository at this point in the history
…access control lists
  • Loading branch information
jon-humphries committed Jul 23, 2024
1 parent 9483ab3 commit e720857
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions meraki_networks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,37 @@ resource "meraki_networks_snmp" "snmp_settings" {
# # rules_response = try(each.value.data.rules_response, null)
# }

locals {
network_acls = flatten([
for domain in try(local.meraki.domains, []) : [
for org in try(domain.organizations, []) : [
for network in try(org.networks, []) : {
network_id = meraki_networks.networks["${domain.name}/${org.name}/${network.name}"].id
switch_access_control_lists = {
rules = [for rule in try(network.switch_access_control_lists.rules, []) : {
comment = try(rule.comment, null)
policy = try(rule.policy, null)
ip_version = try(rule.ip_version, null)
protocol = try(rule.protocol, null)
src_cidr = try(rule.src_cidr, null)
src_port = try(rule.src_port, null)
dst_cidr = try(rule.dst_cidr, null)
dst_port = try(rule.dst_port, null)
vlan = try(rule.vlan, null)
}]
}
}
]
]
])
}

resource "meraki_networks_switch_access_control_lists" "example" {
for_each = { for i, v in local.network_acls : i => v }

network_id = each.value.network_id
rules = each.value.switch_access_control_lists.rules
}

# locals {
# networks_switch_access_policies = flatten([
Expand Down

0 comments on commit e720857

Please sign in to comment.