forked from netascode/terraform-sdwan-nac-sdwan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sdwan_policy_objects.tf
175 lines (155 loc) · 7.14 KB
/
sdwan_policy_objects.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
resource "sdwan_application_list_policy_object" "application_list_policy_object" {
for_each = { for p in try(local.policy_objects.application_lists, {}) : p.name => p }
name = each.value.name
# entries = [for e in try(each.value.entries, []) : {
entries = [for e in concat([for app in try(each.value.applications, []) : { "application" : app }], [for fam in try(each.value.application_families, []) : { "application_family" : fam }]) : {
application = try(e.application, null)
application_family = try(e.application_family, null)
}]
}
resource "sdwan_as_path_list_policy_object" "as_path_list_policy_object" {
for_each = { for p in try(local.policy_objects.as_path_lists, {}) : p.name => p }
name = each.value.name
entries = [for e in try(each.value.as_paths, []) : {
as_path = e
}]
}
resource "sdwan_class_map_policy_object" "class_map_policy_object" {
for_each = { for p in try(local.policy_objects.class_maps, {}) : p.name => p }
name = each.value.name
queue = each.value.queue
}
resource "sdwan_color_list_policy_object" "color_list_policy_object" {
for_each = { for p in try(local.policy_objects.color_lists, {}) : p.name => p }
name = each.value.name
entries = [for e in try(each.value.colors, []) : {
color = e
}]
}
resource "sdwan_standard_community_list_policy_object" "standard_community_list_policy_object" {
for_each = { for p in try(local.policy_objects.standard_community_lists, {}) : p.name => p }
name = each.value.name
entries = [for e in try(each.value.standard_communities, []) : {
community = e
}]
}
resource "sdwan_data_ipv4_prefix_list_policy_object" "data_ipv4_prefix_list_policy_object" {
for_each = { for p in try(local.policy_objects.ipv4_data_prefix_lists, {}) : p.name => p }
name = each.value.name
entries = [for e in try(each.value.prefixes, []) : {
prefix = e
}]
}
resource "sdwan_expanded_community_list_policy_object" "expanded_community_list_policy_object" {
for_each = { for p in try(local.policy_objects.expanded_community_lists, {}) : p.name => p }
name = each.value.name
entries = [for e in try(each.value.expanded_communities, []) : {
community = e
}]
}
resource "sdwan_extended_community_list_policy_object" "extended_community_list_policy_object" {
for_each = { for p in try(local.policy_objects.extended_community_lists, {}) : p.name => p }
name = each.value.name
entries = [for e in try(each.value.extended_communities, []) : {
community = e
}]
}
resource "sdwan_policer_policy_object" "policer_policy_object" {
for_each = { for p in try(local.policy_objects.policers, {}) : p.name => p }
name = each.value.name
burst = each.value.burst_bytes
exceed_action = each.value.exceed_action
rate = each.value.rate_bps
}
resource "sdwan_ipv4_prefix_list_policy_object" "ipv4_prefix_list_policy_object" {
for_each = { for p in try(local.policy_objects.ipv4_prefix_lists, {}) : p.name => p }
name = each.value.name
entries = [for e in try(each.value.entries, []) : {
prefix = e.prefix
ge = try(e.ge, null)
le = try(e.le, null)
}]
}
resource "sdwan_mirror_policy_object" "mirror_policy_object" {
for_each = { for p in try(local.policy_objects.mirror_lists, {}) : p.name => p }
name = each.value.name
remote_destination_ip = each.value.remote_destination_ip
source_ip = each.value.source_ip
}
resource "sdwan_site_list_policy_object" "site_list_policy_object" {
for_each = { for p in try(local.policy_objects.site_lists, {}) : p.name => p }
name = each.value.name
entries = [for e in concat(try(each.value.site_ids, []), [for r in try(each.value.site_id_ranges, []) : "${r.from}-${r.to}"]) : {
site_id = e
}]
}
resource "sdwan_sla_class_policy_object" "sla_class_policy_object" {
for_each = { for p in try(local.policy_objects.sla, {}) : p.name => p }
name = each.value.name
jitter = each.value.jitter_ms
latency = each.value.latency_ms
loss = each.value.loss_percentage
fallback_best_tunnel_criteria = each.value.fallback_best_tunnel_criteria
fallback_best_tunnel_jitter = each.value.fallback_best_tunnel_jitter
fallback_best_tunnel_latency = each.value.fallback_best_tunnel_latency
fallback_best_tunnel_loss = each.value.fallback_best_tunnel_loss
}
resource "sdwan_tloc_list_policy_object" "tloc_list_policy_object" {
for_each = { for p in try(local.policy_objects.tloc_lists, {}) : p.name => p }
name = each.value.name
entries = [for e in try(each.value.tlocs, []) : {
color = e.color
encapsulation = e.encapsulation
tloc_ip = e.tloc_ip
preference = try(e.preference, null)
}]
}
resource "sdwan_vpn_list_policy_object" "vpn_list_policy_object" {
for_each = { for p in try(local.policy_objects.lists.vpn, {}) : p.name => p }
name = each.value.name
entries = [for e in concat(try(each.value.vpn_ids, []), [for r in try(each.value.vpn_id_ranges, []) : "${r.from}-${r.to}"]) : {
vpn_id = e.vpn
}]
}
resource "sdwan_app_probe_class_policy_object" "app_probe_class_policy_object" {
for_each = { for p in try(local.policy_objects.app_probe_classes, {}) : p.name => p }
name = each.value.name
forwarding_class = each.value.forwarding_class
mappings = [for e in try(each.value.mappings, []) : {
color = e.color
dscp = try(e.dscp, null)
}]
}
resource "sdwan_data_ipv6_prefix_list_policy_object" "data_ipv6_prefix_list_policy_object" {
for_each = { for p in try(local.policy_objects.ipv6_data_prefix_lists, {}) : p.name => p }
name = each.value.name
entries = [for e in try(each.value.prefixes, []) : {
prefix = e
}]
}
resource "sdwan_ipv6_prefix_list_policy_object" "ipv6_prefix_list_policy_object" {
for_each = { for p in try(local.policy_objects.ipv6_prefix_lists, {}) : p.name => p }
name = each.value.name
entries = [for e in try(each.value.entries, []) : {
prefix = e.prefix
ge = try(e.ge, null)
le = try(e.le, null)
}]
}
resource "sdwan_preferred_color_group_policy_object" "preferred_color_group_policy_object" {
for_each = { for p in try(local.policy_objects.preferred_color_groups, {}) : p.name => p }
name = each.value.name
primary_color_preference = join(" ", [for c in each.value.primary_colors : c])
primary_path_preference = try(each.value.primary_path, null)
secondary_color_preference = join(" ", [for c in try(each.value.secondary_colors, []) : c])
secondary_path_preference = try(each.value.secondary_path, null)
tertiary_color_preference = join(" ", [for c in try(each.value.tertiary_colors, []) : c])
tertiary_path_preference = try(each.value.tertiary_path, null)
}
resource "sdwan_region_list_policy_object" "region_list_policy_object" {
for_each = { for p in try(local.policy_objects.region_lists, {}) : p.name => p }
name = each.value.name
entries = [for e in toset(concat(try(each.value.region_ids, []), [for r in try(each.value.region_id_ranges, []) : "${r.from}-${r.to}"])) : {
region_id = e
}]
}