Skip to content

Commit

Permalink
refactor: Update meraki_networks.tf to include SNMP settings using lo…
Browse files Browse the repository at this point in the history
…cal variables
  • Loading branch information
jon-humphries committed Jul 23, 2024
1 parent 8922c05 commit 9483ab3
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion meraki_networks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ resource "meraki_networks_group_policies" "net_group_policies" {
}
}


# marcin code
# locals {
# networks_settings = flatten([
# for domain in try(local.meraki.domains, []) : [
Expand Down Expand Up @@ -245,6 +245,35 @@ resource "meraki_networks_settings" "net_settings" {
}
}

locals {
network_snmp_settings = 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
snmp = {
community_string = try(network.snmp.community_string, null)
access = try(network.snmp.access, null)
users = [for user in try(network.snmp.users, []) : {
username = try(user.username, null)
passphrase = try(user.passphrase, null)
}]
}
}
]
]
])
}

resource "meraki_networks_snmp" "snmp_settings" {
for_each = { for i, v in local.network_snmp_settings : i => v }

network_id = each.value.network_id
community_string = each.value.snmp.community_string
access = each.value.snmp.access
users = each.value.snmp.users
}


# locals {
# networks_switch_access_control_lists = flatten([
Expand Down

0 comments on commit 9483ab3

Please sign in to comment.