This repository has been archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
1920 lines (1762 loc) · 128 KB
/
main.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
locals {
user_defaults = { "defaults" : try(var.model.defaults, {}) }
defaults = yamldecode(data.utils_yaml_merge.defaults.output)["defaults"]
modules = try(var.model.modules, {})
apic = try(var.model.apic, {})
access_policies = try(local.apic.access_policies, {})
node_policies = try(local.apic.node_policies, {})
interface_policies = try(local.apic.interface_policies, {})
tenant = [for tenant in try(local.apic.tenants, {}) : tenant if tenant.name == var.tenant_name][0]
leaf_interface_policy_group_mapping = [
for pg in try(local.access_policies.leaf_interface_policy_groups, []) : {
name = pg.name
type = pg.type
node_ids = [
for node in try(local.interface_policies.nodes, []) :
node.id if length([for int in node.interfaces : try(int.policy_group, null) if try(int.policy_group, null) == pg.name]) > 0
]
}
]
# first iteration to resolve node_id and determine IPG type for static ports
endpoint_groups = flatten([for ap in try(local.tenant.application_profiles, []) : [
for epg in try(ap.endpoint_groups, []) : {
key = "${ap.name}/${epg.name}"
value = {
application_profile = "${ap.name}${local.defaults.apic.tenants.application_profiles.name_suffix}"
name = "${epg.name}${local.defaults.apic.tenants.application_profiles.endpoint_groups.name_suffix}"
alias = try(epg.alias, "")
description = try(epg.description, "")
flood_in_encap = try(epg.flood_in_encap, local.defaults.apic.tenants.application_profiles.endpoint_groups.flood_in_encap)
intra_epg_isolation = try(epg.intra_epg_isolation, local.defaults.apic.tenants.application_profiles.endpoint_groups.intra_epg_isolation)
preferred_group = try(epg.preferred_group, local.defaults.apic.tenants.application_profiles.endpoint_groups.preferred_group)
qos_class = try(epg.qos_class, local.defaults.apic.tenants.application_profiles.endpoint_groups.qos_class)
custom_qos_policy = try("${epg.custom_qos_policy}${local.defaults.apic.tenants.policies.custom_qos.name_suffix}", "")
bridge_domain = try("${epg.bridge_domain}${local.defaults.apic.tenants.bridge_domains.name_suffix}", "")
tags = try(epg.tags, [])
trust_control_policy = try("${epg.trust_control_policy}${local.defaults.apic.tenants.policies.trust_control_policies.name_suffix}", "")
contract_consumers = try([for contract in epg.contracts.consumers : "${contract}${local.defaults.apic.tenants.contracts.name_suffix}"], [])
contract_providers = try([for contract in epg.contracts.providers : "${contract}${local.defaults.apic.tenants.contracts.name_suffix}"], [])
contract_imported_consumers = try([for contract in epg.contracts.imported_consumers : "${contract}${local.defaults.apic.tenants.imported_contracts.name_suffix}"], [])
contract_intra_epgs = try([for contract in epg.contracts.intra_epgs : "${contract}${local.defaults.apic.tenants.contracts.name_suffix}"], [])
physical_domains = try([for domain in epg.physical_domains : "${domain}${local.defaults.apic.access_policies.physical_domains.name_suffix}"], [])
subnets = [for subnet in try(epg.subnets, []) : {
description = try(subnet.description, "")
ip = subnet.ip
public = try(subnet.public, local.defaults.apic.tenants.application_profiles.endpoint_groups.subnets.public)
shared = try(subnet.shared, local.defaults.apic.tenants.application_profiles.endpoint_groups.subnets.shared)
igmp_querier = try(subnet.igmp_querier, local.defaults.apic.tenants.application_profiles.endpoint_groups.subnets.igmp_querier)
nd_ra_prefix = try(subnet.nd_ra_prefix, local.defaults.apic.tenants.application_profiles.endpoint_groups.subnets.nd_ra_prefix)
no_default_gateway = try(subnet.no_default_gateway, local.defaults.apic.tenants.application_profiles.endpoint_groups.subnets.no_default_gateway)
next_hop_ip = try(subnet.next_hop_ip, "")
anycast_mac = try(subnet.anycast_mac, "")
nlb_group = try(subnet.nlb_group, "0.0.0.0")
nlb_mac = try(subnet.nlb_mac, "00:00:00:00:00:00")
nlb_mode = try(subnet.nlb_mode, "")
ip_pools = [for pool in try(subnet.ip_pools, []) : {
name = "${pool.name}${local.defaults.apic.tenants.application_profiles.endpoint_groups.subnets.ip_pools.name_suffix}"
start_ip = try(pool.start_ip, "")
end_ip = try(pool.end_ip, "")
dns_search_suffix = try(pool.dns_search_suffix, "")
dns_server = try(pool.dns_server, "")
dns_suffix = try(pool.dns_suffix, "")
wins_server = try(pool.wins_server, "")
}]
}]
vmware_vmm_domains = [for vmm in try(epg.vmware_vmm_domains, []) : {
name = "${vmm.name}${local.defaults.apic.fabric_policies.vmware_vmm_domains.name_suffix}"
u_segmentation = try(vmm.u_segmentation, local.defaults.apic.tenants.application_profiles.endpoint_groups.vmware_vmm_domains.u_segmentation)
delimiter = try(vmm.delimiter, local.defaults.apic.tenants.application_profiles.endpoint_groups.vmware_vmm_domains.delimiter)
vlan = try(vmm.vlan, null)
primary_vlan = try(vmm.primary_vlan, null)
secondary_vlan = try(vmm.secondary_vlan, null)
netflow = try(vmm.netflow, local.defaults.apic.tenants.application_profiles.endpoint_groups.vmware_vmm_domains.netflow)
deployment_immediacy = try(vmm.deployment_immediacy, local.defaults.apic.tenants.application_profiles.endpoint_groups.vmware_vmm_domains.deployment_immediacy)
resolution_immediacy = try(vmm.resolution_immediacy, local.defaults.apic.tenants.application_profiles.endpoint_groups.vmware_vmm_domains.resolution_immediacy)
allow_promiscuous = try(vmm.allow_promiscuous, local.defaults.apic.tenants.application_profiles.endpoint_groups.vmware_vmm_domains.allow_promiscuous) == "accept" ? true : false
forged_transmits = try(vmm.forged_transmits, local.defaults.apic.tenants.application_profiles.endpoint_groups.vmware_vmm_domains.forged_transmits) == "accept" ? true : false
mac_changes = try(vmm.mac_changes, local.defaults.apic.tenants.application_profiles.endpoint_groups.vmware_vmm_domains.mac_changes) == "accept" ? true : false
custom_epg_name = try(vmm.custom_epg_name, "")
elag = try(vmm.elag, "")
active_uplinks_order = try(vmm.active_uplinks_order, "")
standby_uplinks = try(vmm.standby_uplinks, "")
}]
static_ports = [for sp in try(epg.static_ports, []) : {
node_id = try(sp.node_id, [for pg in local.leaf_interface_policy_group_mapping : pg.node_ids if pg.name == sp.channel][0][0], null)
# set node2_id to "vpc" if channel IPG is vPC, otherwise "null"
node2_id = try(sp.node2_id, [for pg in local.leaf_interface_policy_group_mapping : pg.type if pg.name == sp.channel && pg.type == "vpc"][0], null)
fex_id = try(sp.fex_id, null)
fex2_id = try(sp.fex2_id, null)
pod_id = try(sp.pod_id, null)
channel = try("${sp.channel}${local.defaults.apic.access_policies.leaf_interface_policy_groups.name_suffix}", null)
port = try(sp.port, null)
sub_port = try(sp.sub_port, null)
module = try(sp.module, null)
vlan = try(sp.vlan, null)
deployment_immediacy = try(sp.deployment_immediacy, local.defaults.apic.tenants.application_profiles.endpoint_groups.static_ports.deployment_immediacy)
mode = try(sp.mode, local.defaults.apic.tenants.application_profiles.endpoint_groups.static_ports.mode)
}]
static_endpoints = [for se in try(epg.static_endpoints, []) : {
name = "${se.name}${local.defaults.apic.tenants.application_profiles.endpoint_groups.static_endpoints.name_suffix}"
alias = try(se.alias, "")
mac = se.mac
ip = try(se.ip, local.defaults.apic.tenants.application_profiles.endpoint_groups.static_endpoints.ip)
type = se.type
node_id = try(se.node_id, [for pg in local.leaf_interface_policy_group_mapping : pg.node_ids if pg.name == se.channel][0][0], null)
# set node2_id to "vpc" if channel IPG is vPC, otherwise "null"
node2_id = try(se.node2_id, [for pg in local.leaf_interface_policy_group_mapping : pg.type if pg.name == se.channel && pg.type == "vpc"][0], null)
pod_id = try(se.pod_id, 1)
channel = try("${se.channel}${local.defaults.apic.access_policies.leaf_interface_policy_groups.name_suffix}", null)
port = try(se.port, null)
module = try(se.module, 1)
vlan = try(se.vlan, null)
additional_ips = try(se.additional_ips, [])
}]
l4l7_virtual_ips = [for vip in try(epg.l4l7_virtual_ips, []) : {
ip = vip.ip
description = try(vip.description, "")
}]
l4l7_address_pools = [for ap in try(epg.l4l7_address_pools, []) : {
name = ap.name
gateway_address = ap.gateway_address
from = try(ap.from, "")
to = try(ap.to, "")
}]
}
}]
])
endpoint_security_groups = flatten([for ap in try(local.tenant.application_profiles, []) : [
for esg in try(ap.endpoint_security_groups, []) : {
key = "${ap.name}/${esg.name}"
value = {
application_profile = "${ap.name}${local.defaults.apic.tenants.application_profiles.name_suffix}"
name = "${esg.name}${local.defaults.apic.tenants.application_profiles.endpoint_security_groups.name_suffix}"
description = try(esg.description, "")
vrf = "${esg.vrf}${local.defaults.apic.tenants.vrfs.name_suffix}"
shutdown = try(esg.shutdown, local.defaults.apic.tenants.application_profiles.endpoint_security_groups.shutdown)
intra_esg_isolation = try(esg.intra_esg_isolation, local.defaults.apic.tenants.application_profiles.endpoint_security_groups.intra_esg_isolation)
preferred_group = try(esg.preferred_group, local.defaults.apic.tenants.application_profiles.endpoint_security_groups.preferred_group)
contract_consumers = try([for contract in esg.contracts.consumers : "${contract}${local.defaults.apic.tenants.contracts.name_suffix}"], [])
contract_providers = try([for contract in esg.contracts.providers : "${contract}${local.defaults.apic.tenants.contracts.name_suffix}"], [])
contract_imported_consumers = try([for contract in esg.contracts.imported_consumers : "${contract}${local.defaults.apic.tenants.imported_contracts.name_suffix}"], [])
contract_intra_esgs = try([for contract in esg.contracts.intra_esgs : "${contract}${local.defaults.apic.tenants.contracts.name_suffix}"], [])
esg_contract_masters = [for master in try(esg.contracts.masters, []) : {
tenant = local.tenant.name
application_profile = "${try(master.application_profile, ap.name)}${local.defaults.apic.tenants.application_profiles.name_suffix}"
endpoint_security_group = "${master.endpoint_security_group}${local.defaults.apic.tenants.application_profiles.endpoint_security_groups.name_suffix}"
}]
tag_selectors = [for sel in try(esg.tag_selectors, []) : {
key = sel.key
operator = try(sel.operator, local.defaults.apic.tenants.application_profiles.endpoint_security_groups.tag_selectors.operator)
value = sel.value
description = try(sel.description, "")
}]
epg_selectors = [for sel in try(esg.epg_selectors, []) : {
tenant = local.tenant.name
application_profile = "${try(sel.application_profile, ap.name)}${local.defaults.apic.tenants.application_profiles.name_suffix}"
endpoint_group = "${sel.endpoint_group}${local.defaults.apic.tenants.application_profiles.endpoint_groups.name_suffix}"
description = try(sel.description, "")
}]
ip_subnet_selectors = [for sel in try(esg.ip_subnet_selectors, []) : {
value = sel.value
description = try(sel.description, "")
}]
}
}]
])
l3outs = [for l3out in try(local.tenant.l3outs, []) : {
name = "${l3out.name}${local.defaults.apic.tenants.l3outs.name_suffix}"
alias = try(l3out.alias, "")
description = try(l3out.description, "")
domain = "${l3out.domain}${local.defaults.apic.access_policies.routed_domains.name_suffix}"
vrf = "${l3out.vrf}${local.defaults.apic.tenants.vrfs.name_suffix}"
bgp = anytrue([
anytrue([
for np in try(l3out.node_profiles, []) : try(np.bgp_peers, null) != null
]),
anytrue(
flatten([for np in try(l3out.node_profiles, []) : [
for ip in try(np.interface_profiles, []) : [
for int in try(ip.interfaces, []) : try(int.bgp_peers, null) != null
]
]])
),
try(l3out.bgp_peers, null) != null,
anytrue(
flatten([for node in try(l3out.nodes, []) : [
for int in try(node.interfaces, []) : try(int.bgp_peers, null) != null
]])
),
])
ospf = try(l3out.ospf, null) != null ? true : false
ospf_area = can(tonumber(try(l3out.ospf.area, "backbone"))) ? (tonumber(try(l3out.ospf.area, "backbone")) == 0 ? "backbone" : "0.0.0.${tonumber(try(l3out.ospf.area, "backbone"))}") : try(l3out.ospf.area, "backbone")
ospf_area_cost = try(l3out.ospf.area_cost, local.defaults.apic.tenants.l3outs.ospf.area_cost)
ospf_area_type = try(l3out.ospf.area_type, local.defaults.apic.tenants.l3outs.ospf.area_type)
l3_multicast_ipv4 = try(l3out.l3_multicast_ipv4, local.defaults.apic.tenants.l3outs.l3_multicast_ipv4)
target_dscp = try(l3out.target_dscp, local.defaults.apic.tenants.l3outs.target_dscp)
interleak_route_map = try("${l3out.interleak_route_map}${local.defaults.apic.tenants.policies.route_control_route_maps.name_suffix}", "")
dampening_ipv4_route_map = try("${l3out.dampening_ipv4_route_map}${local.defaults.apic.tenants.policies.route_control_route_maps.name_suffix}", "")
dampening_ipv6_route_map = try("${l3out.dampening_ipv6_route_map}${local.defaults.apic.tenants.policies.route_control_route_maps.name_suffix}", "")
default_route_leak_policy = try(l3out.default_route_leak_policy, null) != null ? true : false
default_route_leak_policy_always = try(l3out.default_route_leak_policy.always, local.defaults.apic.tenants.l3outs.default_route_leak_policy.always)
default_route_leak_policy_criteria = try(l3out.default_route_leak_policy.criteria, local.defaults.apic.tenants.l3outs.default_route_leak_policy.criteria)
default_route_leak_policy_context_scope = try(l3out.default_route_leak_policy.context_scope, local.defaults.apic.tenants.l3outs.default_route_leak_policy.context_scope)
default_route_leak_policy_outside_scope = try(l3out.default_route_leak_policy.outside_scope, local.defaults.apic.tenants.l3outs.default_route_leak_policy.outside_scope)
redistribution_route_maps = [for routemap in try(l3out.redistribution_route_maps, []) : {
source = try(routemap.source, local.defaults.apic.tenants.l3outs.redistribution_route_maps.source)
route_map = "${routemap.route_map}${local.defaults.apic.tenants.policies.route_control_route_maps.name_suffix}"
}]
import_route_map_description = try(l3out.import_route_map.description, "")
import_route_map_type = try(l3out.import_route_map.type, local.defaults.apic.tenants.l3outs.import_route_map.type)
import_route_map_contexts = [for context in try(l3out.import_route_map.contexts, []) : {
name = "${context.name}${local.defaults.apic.tenants.l3outs.import_route_map.contexts.name_suffix}"
description = try(context.description, "")
action = try(context.action, local.defaults.apic.tenants.l3outs.import_route_map.contexts.action)
order = try(context.order, local.defaults.apic.tenants.l3outs.import_route_map.contexts.order)
set_rule = try("${context.set_rule}${local.defaults.apic.tenants.policies.set_rules.name_suffix}", "")
match_rule = try("${context.match_rule}${local.defaults.apic.tenants.policies.match_rules.name_suffix}", "")
}]
export_route_map_description = try(l3out.export_route_map.description, "")
export_route_map_type = try(l3out.export_route_map.type, local.defaults.apic.tenants.l3outs.export_route_map.type)
export_route_map_contexts = [for context in try(l3out.export_route_map.contexts, []) : {
name = "${context.name}${local.defaults.apic.tenants.l3outs.export_route_map.contexts.name_suffix}"
description = try(context.description, "")
action = try(context.action, local.defaults.apic.tenants.l3outs.export_route_map.contexts.action)
order = try(context.order, local.defaults.apic.tenants.l3outs.export_route_map.contexts.order)
set_rule = try("${context.set_rule}${local.defaults.apic.tenants.policies.set_rules.name_suffix}", "")
match_rule = try("${context.match_rule}${local.defaults.apic.tenants.policies.match_rules.name_suffix}", "")
}]
}]
node_profiles_manual = flatten([for l3out in try(local.tenant.l3outs, []) : [
for np in try(l3out.node_profiles, []) : {
key = "${l3out.name}/${np.name}"
value = {
l3out = l3out.name
name = "${np.name}${local.defaults.apic.tenants.l3outs.node_profiles.name_suffix}"
nodes = [for node in try(np.nodes, []) : {
node_id = node.node_id
pod_id = try(node.pod_id, [for node_ in local.node_policies.nodes : node_.pod if node_.id == node.node_id][0], local.defaults.apic.tenants.l3outs.node_profiles.nodes.pod)
router_id = node.router_id
router_id_as_loopback = try(node.router_id_as_loopback, local.defaults.apic.tenants.l3outs.node_profiles.nodes.router_id_as_loopback)
loopback = try(node.loopback, null)
static_routes = [for sr in try(node.static_routes, []) : {
description = try(sr.description, "")
prefix = sr.prefix
preference = try(sr.preference, local.defaults.apic.tenants.l3outs.node_profiles.nodes.static_routes.preference)
bfd = try(sr.bfd, local.defaults.apic.tenants.l3outs.node_profiles.nodes.static_routes.bfd)
next_hops = [for nh in try(sr.next_hops, []) : {
ip = nh.ip
preference = try(nh.preference, local.defaults.apic.tenants.l3outs.node_profiles.nodes.static_routes.next_hops.preference)
type = try(nh.type, local.defaults.apic.tenants.l3outs.node_profiles.nodes.static_routes.next_hops.type)
}]
}]
}]
bgp_peers = [for peer in try(np.bgp_peers, []) : {
ip = peer.ip
remote_as = peer.remote_as
description = try(peer.description, "")
allow_self_as = try(peer.allow_self_as, local.defaults.apic.tenants.l3outs.node_profiles.bgp_peers.allow_self_as)
as_override = try(peer.as_override, local.defaults.apic.tenants.l3outs.node_profiles.bgp_peers.as_override)
disable_peer_as_check = try(peer.disable_peer_as_check, local.defaults.apic.tenants.l3outs.node_profiles.bgp_peers.disable_peer_as_check)
next_hop_self = try(peer.next_hop_self, local.defaults.apic.tenants.l3outs.node_profiles.bgp_peers.next_hop_self)
send_community = try(peer.send_community, local.defaults.apic.tenants.l3outs.node_profiles.bgp_peers.send_community)
send_ext_community = try(peer.send_ext_community, local.defaults.apic.tenants.l3outs.node_profiles.bgp_peers.send_ext_community)
password = try(peer.password, null)
allowed_self_as_count = try(peer.allowed_self_as_count, local.defaults.apic.tenants.l3outs.node_profiles.bgp_peers.allowed_self_as_count)
bfd = try(peer.bfd, local.defaults.apic.tenants.l3outs.node_profiles.bgp_peers.bfd)
disable_connected_check = try(peer.disable_connected_check, local.defaults.apic.tenants.l3outs.node_profiles.bgp_peers.disable_connected_check)
ttl = try(peer.ttl, local.defaults.apic.tenants.l3outs.node_profiles.bgp_peers.ttl)
weight = try(peer.weight, local.defaults.apic.tenants.l3outs.node_profiles.bgp_peers.weight)
remove_all_private_as = try(peer.remove_all_private_as, local.defaults.apic.tenants.l3outs.node_profiles.bgp_peers.remove_all_private_as)
remove_private_as = try(peer.remove_private_as, local.defaults.apic.tenants.l3outs.node_profiles.bgp_peers.remove_private_as)
replace_private_as_with_local_as = try(peer.replace_private_as_with_local_as, local.defaults.apic.tenants.l3outs.node_profiles.bgp_peers.replace_private_as_with_local_as)
unicast_address_family = try(peer.unicast_address_family, local.defaults.apic.tenants.l3outs.node_profiles.bgp_peers.unicast_address_family)
multicast_address_family = try(peer.multicast_address_family, local.defaults.apic.tenants.l3outs.node_profiles.bgp_peers.multicast_address_family)
admin_state = try(peer.admin_state, local.defaults.apic.tenants.l3outs.node_profiles.bgp_peers.admin_state)
local_as = try(peer.local_as, null)
as_propagate = try(peer.as_propagate, local.defaults.apic.tenants.l3outs.node_profiles.bgp_peers.as_propagate)
peer_prefix_policy = try("${peer.peer_prefix_policy}${local.defaults.apic.tenants.policies.bgp_peer_prefix_policies.name_suffix}", null)
export_route_control = try("${peer.export_route_control}${local.defaults.apic.tenants.policies.route_control_route_maps.name_suffix}", null)
import_route_control = try("${peer.import_route_control}${local.defaults.apic.tenants.policies.route_control_route_maps.name_suffix}", null)
}]
}
}]
])
node_profiles_auto = [for l3out in try(local.tenant.l3outs, []) : {
l3out = l3out.name
name = l3out.name
nodes = [for node in try(l3out.nodes, []) : {
node_id = node.node_id
pod_id = try(node.pod_id, [for node_ in local.node_policies.nodes : node_.pod if node_.id == node.node_id][0], local.defaults.apic.tenants.l3outs.nodes.pod)
router_id = node.router_id
router_id_as_loopback = try(node.router_id_as_loopback, local.defaults.apic.tenants.l3outs.nodes.router_id_as_loopback)
loopback = try(node.loopback, null)
static_routes = [for sr in try(node.static_routes, []) : {
description = try(sr.description, "")
prefix = sr.prefix
preference = try(sr.preference, local.defaults.apic.tenants.l3outs.nodes.static_routes.preference)
bfd = try(sr.bfd, local.defaults.apic.tenants.l3outs.node_profiles.nodes.static_routes.bfd)
next_hops = [for nh in try(sr.next_hops, []) : {
ip = nh.ip
preference = try(nh.preference, local.defaults.apic.tenants.l3outs.nodes.static_routes.next_hops.preference)
type = try(nh.type, local.defaults.apic.tenants.l3outs.nodes.static_routes.next_hops.type)
}]
}]
}]
bgp_peers = [for peer in try(l3out.bgp_peers, []) : {
ip = peer.ip
remote_as = peer.remote_as
description = try(peer.description, "")
allow_self_as = try(peer.allow_self_as, local.defaults.apic.tenants.l3outs.bgp_peers.allow_self_as)
as_override = try(peer.as_override, local.defaults.apic.tenants.l3outs.bgp_peers.as_override)
disable_peer_as_check = try(peer.disable_peer_as_check, local.defaults.apic.tenants.l3outs.bgp_peers.disable_peer_as_check)
next_hop_self = try(peer.next_hop_self, local.defaults.apic.tenants.l3outs.bgp_peers.next_hop_self)
send_community = try(peer.send_community, local.defaults.apic.tenants.l3outs.bgp_peers.send_community)
send_ext_community = try(peer.send_ext_community, local.defaults.apic.tenants.l3outs.bgp_peers.send_ext_community)
password = try(peer.password, null)
allowed_self_as_count = try(peer.allowed_self_as_count, local.defaults.apic.tenants.l3outs.bgp_peers.allowed_self_as_count)
bfd = try(peer.bfd, local.defaults.apic.tenants.l3outs.bgp_peers.bfd)
disable_connected_check = try(peer.disable_connected_check, local.defaults.apic.tenants.l3outs.bgp_peers.disable_connected_check)
ttl = try(peer.ttl, local.defaults.apic.tenants.l3outs.bgp_peers.ttl)
weight = try(peer.weight, local.defaults.apic.tenants.l3outs.bgp_peers.weight)
remove_all_private_as = try(peer.remove_all_private_as, local.defaults.apic.tenants.l3outs.bgp_peers.remove_all_private_as)
remove_private_as = try(peer.remove_private_as, local.defaults.apic.tenants.l3outs.bgp_peers.remove_private_as)
replace_private_as_with_local_as = try(peer.replace_private_as_with_local_as, local.defaults.apic.tenants.l3outs.bgp_peers.replace_private_as_with_local_as)
unicast_address_family = try(peer.unicast_address_family, local.defaults.apic.tenants.l3outs.bgp_peers.unicast_address_family)
multicast_address_family = try(peer.multicast_address_family, local.defaults.apic.tenants.l3outs.bgp_peers.multicast_address_family)
admin_state = try(peer.admin_state, local.defaults.apic.tenants.l3outs.bgp_peers.admin_state)
local_as = try(peer.local_as, null)
as_propagate = try(peer.as_propagate, local.defaults.apic.tenants.l3outs.bgp_peers.as_propagate)
peer_prefix_policy = try("${peer.peer_prefix_policy}${local.defaults.apic.tenants.policies.bgp_peer_prefix_policies.name_suffix}", null)
export_route_control = try("${peer.export_route_control}${local.defaults.apic.tenants.policies.route_control_route_maps.name_suffix}", null)
import_route_control = try("${peer.import_route_control}${local.defaults.apic.tenants.policies.route_control_route_maps.name_suffix}", null)
}]
} if length(try(l3out.nodes, [])) != 0]
interface_profiles_manual = flatten([for l3out in try(local.tenant.l3outs, []) : [
for np in try(l3out.node_profiles, []) : [
for ip in try(np.interface_profiles, []) : {
key = "${l3out.name}/${np.name}/${ip.name}"
value = {
l3out = l3out.name
node_profile = np.name
name = "${ip.name}${local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.name_suffix}"
bfd_policy = try("${ip.bfd_policy}${local.defaults.apic.tenants.policies.bfd_interface_policies.name_suffix}", "")
ospf_interface_profile_name = try(ip.ospf.ospf_interface_profile_name, "")
ospf_authentication_key = try(ip.ospf.auth_key, "")
ospf_authentication_key_id = try(ip.ospf.auth_key_id, "1")
ospf_authentication_type = try(ip.ospf.auth_type, "none")
ospf_interface_policy = try(ip.ospf.policy, "")
pim_policy = try("${ip.pim_policy}${local.defaults.apic.tenants.policies.pim_policies.name_suffix}", "")
igmp_interface_policy = try("${ip.igmp_interface_policy}${local.defaults.apic.tenants.policies.igmp_interface_policies.name_suffix}", "")
qos_class = try(ip.qos_class, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.qos_class)
custom_qos_policy = try("${ip.custom_qos_policy}${local.defaults.apic.tenants.policies.custom_qos.name_suffix}", "")
interfaces = [for int in try(ip.interfaces, []) : {
ip = try(int.ip, "")
svi = try(int.svi, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.svi)
floating_svi = try(int.floating_svi, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.floating_svi)
vlan = try(int.vlan, null)
description = try(int.description, "")
type = try(int.port, null) != null ? "access" : try([for pg in local.leaf_interface_policy_group_mapping : pg.type if pg.name == int.channel][0], try(int.node2_id, null) != null ? "vpc" : "pc")
mac = try(int.mac, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.mac)
mtu = try(int.mtu, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.mtu)
node_id = try(int.node_id, try(int.channel, null) != null ? try([for pg in local.leaf_interface_policy_group_mapping : pg.node_ids if pg.name == int.channel][0][0], null) : null)
node2_id = try(int.node2_id, try(int.channel, null) != null ? try([for pg in local.leaf_interface_policy_group_mapping : pg.type if pg.name == int.channel && pg.type == "vpc"][0], null) : null)
pod_id = try(int.pod_id, null)
module = try(int.module, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.module)
port = try(int.port, null)
channel = try("${int.channel}${local.defaults.apic.access_policies.leaf_interface_policy_groups.name_suffix}", null)
ip_a = try(int.ip_a, null)
ip_b = try(int.ip_b, null)
ip_shared = try(int.ip_shared, null)
bgp_peers = [for peer in try(int.bgp_peers, []) : {
ip = peer.ip
remote_as = peer.remote_as
description = try(peer.description, "")
allow_self_as = try(peer.allow_self_as, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.allow_self_as)
as_override = try(peer.as_override, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.as_override)
disable_peer_as_check = try(peer.disable_peer_as_check, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.disable_peer_as_check)
next_hop_self = try(peer.next_hop_self, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.next_hop_self)
send_community = try(peer.send_community, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.send_community)
send_ext_community = try(peer.send_ext_community, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.send_ext_community)
password = try(peer.password, null)
allowed_self_as_count = try(peer.allowed_self_as_count, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.allowed_self_as_count)
bfd = try(peer.bfd, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.bfd)
disable_connected_check = try(peer.disable_connected_check, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.disable_connected_check)
ttl = try(peer.ttl, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.ttl)
weight = try(peer.weight, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.weight)
remove_all_private_as = try(peer.remove_all_private_as, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.remove_all_private_as)
remove_private_as = try(peer.remove_private_as, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.remove_private_as)
replace_private_as_with_local_as = try(peer.replace_private_as_with_local_as, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.replace_private_as_with_local_as)
unicast_address_family = try(peer.unicast_address_family, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.unicast_address_family)
multicast_address_family = try(peer.multicast_address_family, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.multicast_address_family)
admin_state = try(peer.admin_state, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.admin_state)
local_as = try(peer.local_as, null)
as_propagate = try(peer.as_propagate, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.as_propagate)
peer_prefix_policy = try("${peer.peer_prefix_policy}${local.defaults.apic.tenants.policies.bgp_peer_prefix_policies.name_suffix}", null)
export_route_control = try("${peer.export_route_control}${local.defaults.apic.tenants.policies.route_control_route_maps.name_suffix}", null)
import_route_control = try("${peer.import_route_control}${local.defaults.apic.tenants.policies.route_control_route_maps.name_suffix}", null)
}]
paths = [for path in try(int.paths, []) : {
physical_domain = path.physical_domain
floating_ip = path.floating_ip
}]
}]
}
}
]
]])
interface_profiles_auto = [for l3out in try(local.tenant.l3outs, []) : {
l3out = l3out.name
node_profile = l3out.name
name = l3out.name
bfd_policy = try("${l3out.bfd_policy}${local.defaults.apic.tenants.policies.bfd_interface_policies.name_suffix}", "")
ospf_interface_profile_name = try(l3out.ospf.ospf_interface_profile_name, l3out.name)
ospf_authentication_key = try(l3out.ospf.auth_key, "")
ospf_authentication_key_id = try(l3out.ospf.auth_key_id, "1")
ospf_authentication_type = try(l3out.ospf.auth_type, "none")
ospf_interface_policy = try(l3out.ospf.policy, "")
pim_policy = try("${l3out.pim_policy}${local.defaults.apic.tenants.policies.pim_policies.name_suffix}", "")
igmp_interface_policy = try("${l3out.igmp_interface_policy}${local.defaults.apic.tenants.policies.igmp_interface_policies.name_suffix}", "")
qos_class = try(l3out.qos_class, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.qos_class)
custom_qos_policy = try("${l3out.custom_qos_policy}${local.defaults.apic.tenants.policies.custom_qos.name_suffix}", "")
interfaces = flatten([for node in try(l3out.nodes, []) : [
for int in try(node.interfaces, []) : {
ip = try(int.ip, "")
svi = try(int.svi, local.defaults.apic.tenants.l3outs.nodes.interfaces.svi)
floating_svi = try(int.floating_svi, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.floating_svi)
vlan = try(int.vlan, null)
description = try(int.description, "")
type = try(int.port, null) != null ? "access" : try([for pg in local.leaf_interface_policy_group_mapping : pg.type if pg.name == int.channel][0], try(int.node2_id, null) != null ? "vpc" : "pc")
mac = try(int.mac, local.defaults.apic.tenants.l3outs.nodes.interfaces.mac)
mtu = try(int.mtu, local.defaults.apic.tenants.l3outs.nodes.interfaces.mtu)
node_id = try(node.node_id, [for pg in local.leaf_interface_policy_group_mapping : pg.node_ids if pg.name == int.channel][0][0], null)
node2_id = try(int.node2_id, [for pg in local.leaf_interface_policy_group_mapping : pg.type if pg.name == int.channel && pg.type == "vpc"][0], null)
pod_id = try(int.pod_id, null)
module = try(int.module, local.defaults.apic.tenants.l3outs.nodes.interfaces.module)
port = try(int.port, null)
channel = try("${int.channel}${local.defaults.apic.access_policies.leaf_interface_policy_groups.name_suffix}", null)
ip_a = try(int.ip_a, null)
ip_b = try(int.ip_b, null)
ip_shared = try(int.ip_shared, null)
bgp_peers = [for peer in try(int.bgp_peers, []) : {
ip = peer.ip
remote_as = peer.remote_as
description = try(peer.description, "")
allow_self_as = try(peer.allow_self_as, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.allow_self_as)
as_override = try(peer.as_override, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.as_override)
disable_peer_as_check = try(peer.disable_peer_as_check, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.disable_peer_as_check)
next_hop_self = try(peer.next_hop_self, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.next_hop_self)
send_community = try(peer.send_community, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.send_community)
send_ext_community = try(peer.send_ext_community, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.send_ext_community)
password = try(peer.password, null)
allowed_self_as_count = try(peer.allowed_self_as_count, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.allowed_self_as_count)
bfd = try(peer.bfd, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.bfd)
disable_connected_check = try(peer.disable_connected_check, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.disable_connected_check)
ttl = try(peer.ttl, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.ttl)
weight = try(peer.weight, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.weight)
remove_all_private_as = try(peer.remove_all_private_as, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.remove_all_private_as)
remove_private_as = try(peer.remove_private_as, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.remove_private_as)
replace_private_as_with_local_as = try(peer.replace_private_as_with_local_as, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.replace_private_as_with_local_as)
unicast_address_family = try(peer.unicast_address_family, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.unicast_address_family)
multicast_address_family = try(peer.multicast_address_family, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.multicast_address_family)
admin_state = try(peer.admin_state, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.admin_state)
local_as = try(peer.local_as, null)
as_propagate = try(peer.as_propagate, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.bgp_peers.as_propagate)
peer_prefix_policy = try("${peer.peer_prefix_policy}${local.defaults.apic.tenants.policies.bgp_peer_prefix_policies.name_suffix}", null)
export_route_control = try("${peer.export_route_control}${local.defaults.apic.tenants.policies.route_control_route_maps.name_suffix}", null)
import_route_control = try("${peer.import_route_control}${local.defaults.apic.tenants.policies.route_control_route_maps.name_suffix}", null)
}]
paths = [for path in try(int.paths, []) : {
physical_domain = path.physical_domain
floating_ip = path.floating_ip
}]
}
]])
} if length(try(l3out.nodes, [])) != 0]
external_endpoint_groups = flatten([for l3out in try(local.tenant.l3outs, []) : [
for epg in try(l3out.external_endpoint_groups, []) : {
key = "${l3out.name}/${epg.name}"
value = {
l3out = "${l3out.name}${local.defaults.apic.tenants.l3outs.name_suffix}"
name = "${epg.name}${local.defaults.apic.tenants.l3outs.external_endpoint_groups.name_suffix}"
alias = try(epg.alias, "")
description = try(epg.description, "")
preferred_group = try(epg.preferred_group, local.defaults.apic.tenants.l3outs.external_endpoint_groups.preferred_group)
qos_class = try(epg.qos_class, local.defaults.apic.tenants.l3outs.external_endpoint_groups.qos_class)
target_dscp = try(epg.target_dscp, local.defaults.apic.tenants.l3outs.external_endpoint_groups.target_dscp)
contract_consumers = try([for contract in epg.contracts.consumers : "${contract}${local.defaults.apic.tenants.contracts.name_suffix}"], [])
contract_providers = try([for contract in epg.contracts.providers : "${contract}${local.defaults.apic.tenants.contracts.name_suffix}"], [])
contract_imported_consumers = try([for contract in epg.contracts.imported_consumers : "${contract}${local.defaults.apic.tenants.imported_contracts.name_suffix}"], [])
subnets = [for subnet in try(epg.subnets, []) : {
name = try(subnet.name, "")
prefix = subnet.prefix
import_route_control = try(subnet.import_route_control, local.defaults.apic.tenants.l3outs.external_endpoint_groups.subnets.import_route_control)
export_route_control = try(subnet.export_route_control, local.defaults.apic.tenants.l3outs.external_endpoint_groups.subnets.export_route_control)
shared_route_control = try(subnet.shared_route_control, local.defaults.apic.tenants.l3outs.external_endpoint_groups.subnets.shared_route_control)
import_security = try(subnet.import_security, local.defaults.apic.tenants.l3outs.external_endpoint_groups.subnets.import_security)
shared_security = try(subnet.shared_security, local.defaults.apic.tenants.l3outs.external_endpoint_groups.subnets.shared_security)
aggregate_import_route_control = try(subnet.aggregate_import_route_control, local.defaults.apic.tenants.l3outs.external_endpoint_groups.subnets.aggregate_import_route_control)
aggregate_export_route_control = try(subnet.aggregate_export_route_control, local.defaults.apic.tenants.l3outs.external_endpoint_groups.subnets.aggregate_export_route_control)
aggregate_shared_route_control = try(subnet.aggregate_shared_route_control, local.defaults.apic.tenants.l3outs.external_endpoint_groups.subnets.aggregate_shared_route_control)
bgp_route_summarization = try(subnet.bgp_route_summarization, local.defaults.apic.tenants.l3outs.external_endpoint_groups.subnets.bgp_route_summarization)
}]
}
}]
])
l4l7_devices = [for device in try(local.tenant.services.l4l7_devices, []) : {
name = "${device.name}${local.defaults.apic.tenants.services.l4l7_devices.name_suffix}"
alias = try(device.alias, "")
context_aware = try(device.context_aware, local.defaults.apic.tenants.services.l4l7_devices.context_aware)
type = try(device.type, local.defaults.apic.tenants.services.l4l7_devices.type)
function = try(device.function, local.defaults.apic.tenants.services.l4l7_devices.function)
copy_device = try(device.copy_device, local.defaults.apic.tenants.services.l4l7_devices.copy_device)
managed = try(device.managed, local.defaults.apic.tenants.services.l4l7_devices.managed)
promiscuous_mode = try(device.promiscuous_mode, local.defaults.apic.tenants.services.l4l7_devices.promiscuous_mode)
service_type = try(device.service_type, local.defaults.apic.tenants.services.l4l7_devices.service_type)
trunking = try(device.trunking, local.defaults.apic.tenants.services.l4l7_devices.trunking)
physical_domain = try(device.physical_domain, "")
vmm_provider = "VMware"
vmm_domain = try(device.vmware_vmm_domain, "")
concrete_devices = [for cdev in try(device.concrete_devices, []) : {
name = "${cdev.name}${local.defaults.apic.tenants.services.l4l7_devices.concrete_devices.name_suffix}"
alias = try(cdev.alias, null)
description = try(cdev.description, null)
vcenter_name = try(cdev.vcenter_name, null)
vm_name = try(cdev.vm_name, null)
interfaces = [for int in try(cdev.interfaces, []) : {
name = "${int.name}${local.defaults.apic.tenants.services.l4l7_devices.concrete_devices.interfaces.name_suffix}"
alias = try(int.alias, null)
vnic_name = try(int.vnic_name, null)
node_id = try(int.node_id, [for pg in local.leaf_interface_policy_group_mapping : pg.node_ids if pg.name == int.channel][0][0], null)
# set node2_id to "vpc" if channel IPG is vPC, otherwise "null"
node2_id = try(int.node2_id, [for pg in local.leaf_interface_policy_group_mapping : pg.type if pg.name == int.channel && pg.type == "vpc"][0], null)
pod_id = try(int.pod_id, [for node in local.node_policies.nodes : node.pod if node.id == int.node_id][0], local.defaults.apic.node_policies.nodes.pod)
fex_id = try(int.fex_id, null)
module = try(int.module, null)
port = try(int.port, null)
channel = try("${int.channel}${local.defaults.apic.access_policies.leaf_interface_policy_groups.name_suffix}", null)
}]
}]
logical_interfaces = [for lint in try(device.logical_interfaces, []) : {
name = "${lint.name}${local.defaults.apic.tenants.services.l4l7_devices.logical_interfaces.name_suffix}"
alias = try(lint.alias, null)
vlan = try(lint.vlan, null)
concrete_interfaces = [for cint in try(lint.concrete_interfaces, []) : {
device = cint.device
interface = "${cint.interface_name}${local.defaults.apic.tenants.services.l4l7_devices.logical_interfaces.concrete_interfaces.name_suffix}"
}]
}]
}]
}
data "utils_yaml_merge" "defaults" {
input = [file("${path.module}/defaults/defaults.yaml"), yamlencode(local.user_defaults)]
}
resource "null_resource" "dependencies" {
triggers = {
dependencies = join(",", var.dependencies)
}
}
module "aci_tenant" {
source = "netascode/tenant/aci"
version = "0.1.0"
count = try(local.tenant.managed, local.defaults.apic.tenants.managed, true) == false || try(local.modules.aci_tenant, true) == false ? 0 : 1
name = local.tenant.name
alias = try(local.tenant.alias, "")
description = try(local.tenant.description, "")
depends_on = [
null_resource.dependencies,
]
}
module "aci_vrf" {
source = "netascode/vrf/aci"
version = "0.2.3"
for_each = { for vrf in try(local.tenant.vrfs, []) : vrf.name => vrf if try(local.modules.aci_vrf, true) }
tenant = local.tenant.name
name = "${each.value.name}${local.defaults.apic.tenants.vrfs.name_suffix}"
alias = try(each.value.alias, "")
description = try(each.value.description, "")
enforcement_direction = try(each.value.enforcement_direction, local.defaults.apic.tenants.vrfs.enforcement_direction)
enforcement_preference = try(each.value.enforcement_preference, local.defaults.apic.tenants.vrfs.enforcement_preference)
data_plane_learning = try(each.value.data_plane_learning, local.defaults.apic.tenants.vrfs.data_plane_learning)
contract_consumers = try([for contract in each.value.contracts.consumers : "${contract}${local.defaults.apic.tenants.contracts.name_suffix}"], [])
contract_providers = try([for contract in each.value.contracts.providers : "${contract}${local.defaults.apic.tenants.contracts.name_suffix}"], [])
contract_imported_consumers = try([for contract in each.value.contracts.imported_consumers : "${contract}${local.defaults.apic.tenants.imported_contracts.name_suffix}"], [])
preferred_group = try(each.value.preferred_group, local.defaults.apic.tenants.vrfs.preferred_group)
bgp_timer_policy = try("${each.value.bgp.timer_policy}${local.defaults.apic.tenants.policies.bgp_timer_policies.name_suffix}", "")
bgp_ipv4_address_family_context_policy = try("${each.value.bgp.ipv4_address_family_context_policy}${local.defaults.apic.tenants.policies.bgp_address_family_context_policies.name_suffix}", "")
bgp_ipv6_address_family_context_policy = try("${each.value.bgp.ipv6_address_family_context_policy}${local.defaults.apic.tenants.policies.bgp_address_family_context_policies.name_suffix}", "")
bgp_ipv4_import_route_target = try(each.value.bgp.ipv4_import_route_target, "")
bgp_ipv4_export_route_target = try(each.value.bgp.ipv4_export_route_target, "")
bgp_ipv6_import_route_target = try(each.value.bgp.ipv6_import_route_target, "")
bgp_ipv6_export_route_target = try(each.value.bgp.ipv6_export_route_target, "")
dns_labels = try(each.value.dns_labels, [])
pim_enabled = try(each.value.pim, null) != null ? true : false
pim_mtu = try(each.value.pim.mtu, local.defaults.apic.tenants.vrfs.pim.mtu)
pim_fast_convergence = try(each.value.pim.fast_convergence, local.defaults.apic.tenants.vrfs.pim.fast_convergence)
pim_strict_rfc = try(each.value.pim.strict_rfc, local.defaults.apic.tenants.vrfs.pim.strict_rfc)
pim_max_multicast_entries = try(each.value.pim.max_multicast_entries, local.defaults.apic.tenants.vrfs.pim.max_multicast_entries)
pim_reserved_multicast_entries = try(each.value.pim.reserved_multicast_entries, local.defaults.apic.tenants.vrfs.pim.reserved_multicast_entries)
pim_resource_policy_multicast_route_map = try(each.value.pim.resource_policy_multicast_route_map, null) != null ? "${each.value.pim.resource_policy_multicast_route_map}${local.defaults.apic.tenants.policies.multicast_route_maps.name_suffix}" : ""
pim_static_rps = [for rp in try(each.value.pim.static_rps, []) : {
ip = rp.ip
multicast_route_map = try(rp.multicast_route_map, null) != null ? "${rp.multicast_route_map}${local.defaults.apic.tenants.policies.multicast_route_maps.name_suffix}" : ""
}]
pim_fabric_rps = [for rp in try(each.value.pim.fabric_rps, []) : {
ip = rp.ip
multicast_route_map = try(rp.multicast_route_map, null) != null ? "${rp.multicast_route_map}${local.defaults.apic.tenants.policies.multicast_route_maps.name_suffix}" : ""
}]
pim_bsr_listen_updates = try(each.value.pim.bsr_listen_updates, local.defaults.apic.tenants.vrfs.pim.bsr_listen_updates)
pim_bsr_forward_updates = try(each.value.pim.bsr_forward_updates, local.defaults.apic.tenants.vrfs.pim.bsr_forward_updates)
pim_bsr_filter_multicast_route_map = try(each.value.pim.bsr_filter_multicast_route_map, null) != null ? "${each.value.pim.bsr_filter_multicast_route_map}${local.defaults.apic.tenants.policies.multicast_route_maps.name_suffix}" : ""
pim_auto_rp_listen_updates = try(each.value.pim.auto_rp_listen_updates, local.defaults.apic.tenants.vrfs.pim.auto_rp_listen_updates)
pim_auto_rp_forward_updates = try(each.value.pim.auto_rp_forward_updates, local.defaults.apic.tenants.vrfs.pim.auto_rp_forward_updates)
pim_auto_rp_filter_multicast_route_map = try(each.value.pim.auto_rp_filter_multicast_route_map, null) != null ? "${each.value.pim.auto_rp_filter_multicast_route_map}${local.defaults.apic.tenants.policies.multicast_route_maps.name_suffix}" : ""
pim_asm_shared_range_multicast_route_map = try(each.value.pim.asm_shared_range_multicast_route_map, null) != null ? "${each.value.pim.asm_shared_range_multicast_route_map}${local.defaults.apic.tenants.policies.multicast_route_maps.name_suffix}" : ""
pim_asm_sg_expiry = try(each.value.pim.asm_sg_expiry, local.defaults.apic.tenants.vrfs.pim.asm_sg_expiry)
pim_asm_sg_expiry_multicast_route_map = try(each.value.pim.asm_sg_expiry_multicast_route_map, null) != null ? "${each.value.pim.asm_sg_expiry_multicast_route_map}${local.defaults.apic.tenants.policies.multicast_route_maps.name_suffix}" : ""
pim_asm_traffic_registry_max_rate = try(each.value.pim.asm_traffic_registry_max_rate, local.defaults.apic.tenants.vrfs.pim.asm_traffic_registry_max_rate)
pim_asm_traffic_registry_source_ip = try(each.value.pim.asm_traffic_registry_source_ip, local.defaults.apic.tenants.vrfs.pim.asm_traffic_registry_source_ip)
pim_ssm_group_range_multicast_route_map = try(each.value.pim.ssm_group_range_multicast_route_map, null) != null ? "${each.value.pim.ssm_group_range_multicast_route_map}${local.defaults.apic.tenants.policies.multicast_route_maps.name_suffix}" : ""
pim_inter_vrf_policies = [for pol in try(each.value.pim.inter_vrf_policies, []) : {
tenant = pol.tenant
vrf = "${pol.vrf}${local.defaults.apic.tenants.vrfs.name_suffix}"
multicast_route_map = try(pol.multicast_route_map, null) != null ? "${pol.multicast_route_map}${local.defaults.apic.tenants.policies.multicast_route_maps.name_suffix}" : ""
}]
pim_igmp_ssm_translate_policies = [for pol in try(each.value.pim.igmp_context_ssm_translate_policies, []) : {
group_prefix = pol.group_prefix
source_address = pol.source_address
}]
leaked_internal_prefixes = [for prefix in try(each.value.leaked_internal_prefixes, []) : {
prefix = prefix.prefix
public = try(prefix.public, local.defaults.apic.tenants.vrfs.leaked_internal_prefixes.public)
destinations = [for dest in try(prefix.destinations, []) : {
description = try(dest.description, "")
tenant = dest.tenant
vrf = dest.vrf
public = try(dest.public, null)
}]
}]
leaked_external_prefixes = [for prefix in try(each.value.leaked_external_prefixes, []) : {
prefix = prefix.prefix
from_prefix_length = try(prefix.from_prefix_length, null)
to_prefix_length = try(prefix.to_prefix_length, null)
destinations = [for dest in try(prefix.destinations, []) : {
description = try(dest.description, "")
tenant = dest.tenant
vrf = dest.vrf
}]
}]
depends_on = [
null_resource.dependencies,
module.aci_tenant,
module.aci_contract,
module.aci_imported_contract,
module.aci_bgp_timer_policy,
]
}
module "aci_bridge_domain" {
source = "netascode/bridge-domain/aci"
version = "0.2.2"
for_each = { for bd in try(local.tenant.bridge_domains, []) : bd.name => bd if try(local.modules.aci_bridge_domain, true) }
tenant = local.tenant.name
name = "${each.value.name}${local.defaults.apic.tenants.bridge_domains.name_suffix}"
alias = try(each.value.alias, "")
description = try(each.value.description, "")
arp_flooding = try(each.value.arp_flooding, local.defaults.apic.tenants.bridge_domains.arp_flooding)
advertise_host_routes = try(each.value.advertise_host_routes, local.defaults.apic.tenants.bridge_domains.advertise_host_routes)
ip_dataplane_learning = try(each.value.ip_dataplane_learning, local.defaults.apic.tenants.bridge_domains.ip_dataplane_learning)
limit_ip_learn_to_subnets = try(each.value.limit_ip_learn_to_subnets, local.defaults.apic.tenants.bridge_domains.limit_ip_learn_to_subnets)
mac = try(each.value.mac, local.defaults.apic.tenants.bridge_domains.mac)
virtual_mac = try(each.value.virtual_mac, "")
ep_move_detection = try(each.value.ep_move_detection, local.defaults.apic.tenants.bridge_domains.ep_move_detection)
l3_multicast = try(each.value.l3_multicast, local.defaults.apic.tenants.bridge_domains.l3_multicast)
multi_destination_flooding = try(each.value.multi_destination_flooding, local.defaults.apic.tenants.bridge_domains.multi_destination_flooding)
unicast_routing = try(each.value.unicast_routing, local.defaults.apic.tenants.bridge_domains.unicast_routing)
unknown_unicast = try(each.value.unknown_unicast, local.defaults.apic.tenants.bridge_domains.unknown_unicast)
unknown_ipv4_multicast = try(each.value.unknown_ipv4_multicast, local.defaults.apic.tenants.bridge_domains.unknown_ipv4_multicast)
vrf = "${each.value.vrf}${local.defaults.apic.tenants.vrfs.name_suffix}"
igmp_interface_policy = try("${each.value.igmp_interface_policy}${local.defaults.apic.tenants.policies.igmp_interface_policies.name_suffix}", "")
igmp_snooping_policy = try("${each.value.igmp_snooping_policy}${local.defaults.apic.tenants.policies.igmp_snooping_policies.name_suffix}", "")
subnets = [for subnet in try(each.value.subnets, []) : {
ip = subnet.ip
description = try(subnet.description, "")
primary_ip = try(subnet.primary_ip, local.defaults.apic.tenants.bridge_domains.subnets.primary_ip)
public = try(subnet.public, local.defaults.apic.tenants.bridge_domains.subnets.public)
shared = try(subnet.shared, local.defaults.apic.tenants.bridge_domains.subnets.shared)
igmp_querier = try(subnet.igmp_querier, local.defaults.apic.tenants.bridge_domains.subnets.igmp_querier)
nd_ra_prefix = try(subnet.nd_ra_prefix, local.defaults.apic.tenants.bridge_domains.subnets.nd_ra_prefix)
no_default_gateway = try(subnet.no_default_gateway, local.defaults.apic.tenants.bridge_domains.subnets.no_default_gateway)
virtual = try(subnet.virtual, local.defaults.apic.tenants.bridge_domains.subnets.virtual)
}]
l3outs = try(each.value.l3outs, null) != null ? [for l3out in each.value.l3outs : "${l3out}${local.defaults.apic.tenants.l3outs.name_suffix}"] : []
dhcp_labels = [for label in try(each.value.dhcp_labels, []) : {
dhcp_relay_policy = try("${label.dhcp_relay_policy}${local.defaults.apic.tenants.policies.dhcp_relay_policies.name_suffix}", "")
dhcp_option_policy = try("${label.dhcp_option_policy}${local.defaults.apic.tenants.policies.dhcp_option_policies.name_suffix}", "")
}]
depends_on = [
null_resource.dependencies,
module.aci_tenant,
module.aci_vrf,
module.aci_l3out,
module.aci_dhcp_relay_policy,
module.aci_dhcp_option_policy,
]
}
module "aci_application_profile" {
source = "netascode/application-profile/aci"
version = "0.1.0"
for_each = { for ap in try(local.tenant.application_profiles, []) : ap.name => ap if try(ap.managed, local.defaults.apic.tenants.application_profiles.managed, true) == true && try(local.modules.aci_application_profile, true) }
tenant = local.tenant.name
name = "${each.value.name}${local.defaults.apic.tenants.application_profiles.name_suffix}"
alias = try(each.value.alias, "")
description = try(each.value.description, "")
depends_on = [
null_resource.dependencies,
module.aci_tenant
]
}
module "aci_endpoint_group" {
source = "netascode/endpoint-group/aci"
version = "0.2.7"
for_each = { for epg in local.endpoint_groups : epg.key => epg.value if try(local.modules.aci_endpoint_group, true) }
tenant = local.tenant.name
application_profile = each.value.application_profile
name = each.value.name
alias = each.value.alias
description = each.value.description
flood_in_encap = each.value.flood_in_encap
intra_epg_isolation = each.value.intra_epg_isolation
preferred_group = each.value.preferred_group
qos_class = each.value.qos_class
custom_qos_policy = each.value.custom_qos_policy
bridge_domain = each.value.bridge_domain
tags = each.value.tags
trust_control_policy = each.value.trust_control_policy
contract_consumers = each.value.contract_consumers
contract_providers = each.value.contract_providers
contract_imported_consumers = each.value.contract_imported_consumers
contract_intra_epgs = each.value.contract_intra_epgs
physical_domains = each.value.physical_domains
subnets = each.value.subnets
vmware_vmm_domains = each.value.vmware_vmm_domains
static_ports = [for sp in try(each.value.static_ports, []) : {
node_id = sp.node_id
node2_id = sp.node2_id == "vpc" ? [for pg in local.leaf_interface_policy_group_mapping : try(pg.node_ids, []) if pg.name == sp.channel][0][1] : sp.node2_id
fex_id = sp.fex_id
fex2_id = sp.fex2_id
pod_id = try(sp.pod_id, [for node in try(local.node_policies.nodes, []) : node.pod if node.id == sp.node_id][0], local.defaults.apic.node_policies.nodes.pod)
channel = sp.channel
port = sp.port
sub_port = sp.sub_port
module = sp.module
vlan = sp.vlan
deployment_immediacy = sp.deployment_immediacy
mode = sp.mode
}]
static_endpoints = [for se in try(each.value.static_endpoints, []) : {
name = se.name
alias = se.alias
mac = se.mac
ip = se.ip
type = se.type
node_id = se.node_id
node2_id = se.node2_id == "vpc" ? [for pg in local.leaf_interface_policy_group_mapping : try(pg.node_ids, []) if pg.name == se.channel][0][1] : se.node2_id
pod_id = try(se.pod_id, [for node in try(local.node_policies.nodes, []) : node.pod if node.id == se.node_id][0], local.defaults.apic.node_policies.nodes.pod)
channel = se.channel
port = se.port
module = se.module
vlan = se.vlan
additional_ips = se.additional_ips
}]
l4l7_virtual_ips = each.value.l4l7_virtual_ips
l4l7_address_pools = each.value.l4l7_address_pools
depends_on = [
null_resource.dependencies,
module.aci_tenant,
module.aci_application_profile,
module.aci_bridge_domain,
module.aci_contract,
module.aci_imported_contract,
]
}
module "aci_endpoint_security_group" {
source = "netascode/endpoint-security-group/aci"
version = "0.2.5"
for_each = { for esg in local.endpoint_security_groups : esg.key => esg.value if try(local.modules.aci_endpoint_security_group, true) }
tenant = local.tenant.name
application_profile = each.value.application_profile
name = each.value.name
description = each.value.description
vrf = each.value.vrf
shutdown = each.value.shutdown
intra_esg_isolation = each.value.intra_esg_isolation
preferred_group = each.value.preferred_group
contract_consumers = each.value.contract_consumers
contract_providers = each.value.contract_providers
contract_imported_consumers = each.value.contract_imported_consumers
contract_intra_esgs = each.value.contract_intra_esgs
esg_contract_masters = each.value.esg_contract_masters
tag_selectors = each.value.tag_selectors
epg_selectors = each.value.epg_selectors
ip_subnet_selectors = each.value.ip_subnet_selectors
depends_on = [
null_resource.dependencies,
module.aci_tenant,
module.aci_application_profile,
module.aci_vrf,
module.aci_contract,
module.aci_endpoint_group,
]
}
module "aci_inband_endpoint_group" {
source = "netascode/inband-endpoint-group/aci"
version = "0.1.1"
for_each = { for epg in try(local.tenant.inb_endpoint_groups, []) : epg.name => epg if local.tenant.name == "mgmt" && try(local.modules.aci_inband_endpoint_group, true) }
name = "${each.value.name}${local.defaults.apic.tenants.inb_endpoint_groups.name_suffix}"
vlan = each.value.vlan
bridge_domain = "${each.value.bridge_domain}${local.defaults.apic.tenants.bridge_domains.name_suffix}"
contract_consumers = try([for contract in each.value.contracts.consumers : "${contract}${local.defaults.apic.tenants.contracts.name_suffix}"], [])
contract_providers = try([for contract in each.value.contracts.providers : "${contract}${local.defaults.apic.tenants.contracts.name_suffix}"], [])
contract_imported_consumers = try([for contract in each.value.contracts.imported_consumers : "${contract}${local.defaults.apic.tenants.imported_contracts.name_suffix}"], [])
depends_on = [
null_resource.dependencies,
module.aci_tenant,
module.aci_contract,
module.aci_imported_contract,
module.aci_bridge_domain,
]
}
module "aci_oob_endpoint_group" {
source = "netascode/oob-endpoint-group/aci"
version = "0.1.0"
for_each = { for epg in try(local.tenant.oob_endpoint_groups, []) : epg.name => epg if local.tenant.name == "mgmt" && try(local.modules.aci_oob_endpoint_group, true) }
name = "${each.value.name}${local.defaults.apic.tenants.oob_endpoint_groups.name_suffix}"
oob_contract_providers = try([for contract in each.value.oob_contracts.providers : "${contract}${local.defaults.apic.tenants.oob_contracts.name_suffix}"], [])
depends_on = [
null_resource.dependencies,
module.aci_tenant,
module.aci_oob_contract,
]
}
module "aci_oob_external_management_instance" {
source = "netascode/oob-external-management-instance/aci"
version = "0.1.0"
for_each = { for ext in try(local.tenant.ext_mgmt_instances, []) : ext.name => ext if local.tenant.name == "mgmt" && try(local.modules.aci_oob_external_management_instance, true) }
name = "${each.value.name}${local.defaults.apic.tenants.ext_mgmt_instances.name_suffix}"
subnets = try(each.value.subnets, [])
oob_contract_consumers = try([for contract in each.value.oob_contracts.consumers : "${contract}${local.defaults.apic.tenants.oob_contracts.name_suffix}"], [])
depends_on = [
null_resource.dependencies,
module.aci_tenant,
module.aci_oob_contract,
]
}
module "aci_l3out" {
source = "netascode/l3out/aci"
version = "0.2.1"
for_each = { for l3out in local.l3outs : l3out.name => l3out if try(local.modules.aci_l3out, true) }
tenant = local.tenant.name
name = each.value.name
alias = each.value.alias
description = each.value.description
routed_domain = each.value.domain
vrf = each.value.vrf
bgp = each.value.bgp
ospf = each.value.ospf
ospf_area = each.value.ospf_area
ospf_area_cost = each.value.ospf_area_cost
ospf_area_type = each.value.ospf_area_type
l3_multicast_ipv4 = each.value.l3_multicast_ipv4
target_dscp = each.value.target_dscp
interleak_route_map = each.value.interleak_route_map
dampening_ipv4_route_map = each.value.dampening_ipv4_route_map
dampening_ipv6_route_map = each.value.dampening_ipv6_route_map
default_route_leak_policy = each.value.default_route_leak_policy
default_route_leak_policy_always = each.value.default_route_leak_policy_always
default_route_leak_policy_criteria = each.value.default_route_leak_policy_criteria
default_route_leak_policy_context_scope = each.value.default_route_leak_policy_context_scope
default_route_leak_policy_outside_scope = each.value.default_route_leak_policy_outside_scope
redistribution_route_maps = each.value.redistribution_route_maps
import_route_map_description = each.value.import_route_map_description
import_route_map_type = each.value.import_route_map_type
import_route_map_contexts = each.value.import_route_map_contexts
export_route_map_description = each.value.export_route_map_description
export_route_map_type = each.value.export_route_map_type
export_route_map_contexts = each.value.export_route_map_contexts
depends_on = [
null_resource.dependencies,
module.aci_tenant,
module.aci_vrf,
module.aci_ospf_interface_policy,
module.aci_bfd_interface_policy,
module.aci_set_rule,
module.aci_match_rule,
]
}
module "aci_l3out_node_profile_manual" {
source = "netascode/l3out-node-profile/aci"
version = "0.2.5"
for_each = { for np in local.node_profiles_manual : np.key => np.value if try(local.modules.aci_l3out_node_profile, true) }
tenant = local.tenant.name
l3out = each.value.l3out
name = each.value.name
nodes = each.value.nodes
bgp_peers = each.value.bgp_peers
depends_on = [
null_resource.dependencies,
module.aci_tenant,
module.aci_l3out,
]
}
module "aci_l3out_node_profile_auto" {
source = "netascode/l3out-node-profile/aci"
version = "0.2.5"
for_each = { for np in local.node_profiles_auto : np.name => np if try(local.modules.aci_l3out_node_profile, true) }
tenant = local.tenant.name
l3out = each.value.l3out
name = each.value.name
nodes = each.value.nodes
bgp_peers = each.value.bgp_peers
depends_on = [
null_resource.dependencies,
module.aci_tenant,
module.aci_l3out,
]
}
module "aci_l3out_interface_profile_manual" {
source = "netascode/l3out-interface-profile/aci"
version = "0.2.5"
for_each = { for ip in local.interface_profiles_manual : ip.key => ip.value if try(local.modules.aci_l3out_interface_profile, true) }
tenant = local.tenant.name
l3out = each.value.l3out
node_profile = each.value.node_profile
name = each.value.name
bfd_policy = each.value.bfd_policy
ospf_interface_profile_name = each.value.ospf_interface_profile_name
ospf_authentication_key = each.value.ospf_authentication_key
ospf_authentication_key_id = each.value.ospf_authentication_key_id
ospf_authentication_type = each.value.ospf_authentication_type
ospf_interface_policy = each.value.ospf_interface_policy
pim_policy = each.value.pim_policy
igmp_interface_policy = each.value.igmp_interface_policy
qos_class = each.value.qos_class
custom_qos_policy = each.value.custom_qos_policy
interfaces = [for int in try(each.value.interfaces, []) : {
ip = int.ip
svi = int.svi
floating_svi = int.floating_svi
vlan = int.vlan
description = int.description
type = int.type
mac = int.mac