-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimc_access.tf
63 lines (62 loc) · 2.5 KB
/
imc_access.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#__________________________________________________________________
#
# Intersight IMC Access Policy
# GUI Location: Policies > Create Policy > IMC Access
#__________________________________________________________________
resource "intersight_access_policy" "map" {
depends_on = [
data.intersight_search_search_item.ip
]
for_each = local.imc_access
description = coalesce(each.value.description, "${each.value.name} IMC Access Policy.")
inband_vlan = each.value.inband_vlan_id
name = each.value.name
address_type {
enable_ip_v4 = each.value.ipv4_address_configuration
enable_ip_v6 = each.value.ipv6_address_configuration
object_type = "access.AddressType"
}
configuration_type {
configure_inband = length(regexall("UNUSED", each.value.inband_ip_pool.name)
) > 0 ? false : true
configure_out_of_band = length(regexall("UNUSED", each.value.out_of_band_ip_pool.name)
) > 0 ? false : true
}
organization {
moid = local.orgs[each.value.organization]
object_type = "organization.Organization"
}
dynamic "inband_ip_pool" {
for_each = {
for v in [each.value.inband_ip_pool.name] : v => v if each.value.inband_ip_pool.name != "UNUSED"
}
content {
moid = length(regexall(false, local.moids_pools)) > 0 ? local.pools[each.value.inband_ip_pool.org].ip[
each.value.inband_ip_pool.name
] : [for i in data.intersight_search_search_item.ip[0].results : i.moid if jsondecode(
i.additional_properties).Organization.Moid == local.orgs[each.value.inband_ip_pool.org
] && jsondecode(i.additional_properties).Name == each.value.inband_ip_pool.name][0]
object_type = "ippool.Pool"
}
}
dynamic "out_of_band_ip_pool" {
for_each = { for v in [each.value.out_of_band_ip_pool.name
] : v => v if each.value.out_of_band_ip_pool.name != "UNUSED"
}
content {
moid = length(regexall(false, local.moids_pools)) > 0 ? local.pools[each.value.out_of_band_ip_pool.org].ip[
each.value.out_of_band_ip_pool.name
] : [for i in data.intersight_search_search_item.ip[0].results : i.moid if jsondecode(
i.additional_properties).Organization.Moid == local.orgs[each.value.out_of_band_ip_pool.org
] && jsondecode(i.additional_properties).Name == each.value.out_of_band_ip_pool.name][0]
object_type = "ippool.Pool"
}
}
dynamic "tags" {
for_each = { for v in each.value.tags : v.key => v }
content {
key = tags.value.key
value = tags.value.value
}
}
}