forked from netascode/terraform-aci-nac-aci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aci_tenants.tf
3608 lines (3364 loc) · 224 KB
/
aci_tenants.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
module "aci_tenant" {
source = "./modules/terraform-aci-tenant"
for_each = { for tenant in local.tenants : tenant.name => tenant if try(tenant.managed, local.defaults.apic.tenants.managed, true) && local.modules.aci_tenant && var.manage_tenants }
name = each.value.name
annotation = try(each.value.ndo_managed, local.defaults.apic.tenants.ndo_managed) ? "orchestrator:msc" : null
alias = try(each.value.alias, "")
description = try(each.value.description, "")
security_domains = try(each.value.security_domains, [])
}
locals {
vrfs = flatten([
for tenant in local.tenants : [
for vrf in try(tenant.vrfs, []) : {
key = format("%s/%s", tenant.name, vrf.name)
tenant = tenant.name
name = "${vrf.name}${local.defaults.apic.tenants.vrfs.name_suffix}"
annotation = try(vrf.ndo_managed, local.defaults.apic.tenants.vrfs.ndo_managed) ? "orchestrator:msc-shadow:no" : null
alias = try(vrf.alias, "")
description = try(vrf.description, "")
enforcement_direction = try(vrf.enforcement_direction, local.defaults.apic.tenants.vrfs.enforcement_direction)
enforcement_preference = try(vrf.enforcement_preference, local.defaults.apic.tenants.vrfs.enforcement_preference)
data_plane_learning = try(vrf.data_plane_learning, local.defaults.apic.tenants.vrfs.data_plane_learning)
contract_consumers = try([for contract in vrf.contracts.consumers : "${contract}${local.defaults.apic.tenants.contracts.name_suffix}"], [])
contract_providers = try([for contract in vrf.contracts.providers : "${contract}${local.defaults.apic.tenants.contracts.name_suffix}"], [])
contract_imported_consumers = try([for contract in vrf.contracts.imported_consumers : "${contract}${local.defaults.apic.tenants.imported_contracts.name_suffix}"], [])
preferred_group = try(vrf.preferred_group, local.defaults.apic.tenants.vrfs.preferred_group)
transit_route_tag_policy = try(vrf.transit_route_tag_policy, null) != null ? "${vrf.transit_route_tag_policy}${local.defaults.apic.tenants.policies.route_tag_policies.name_suffix}" : ""
ospf_timer_policy = try("${vrf.ospf.timer_policy}${local.defaults.apic.tenants.policies.ospf_timer_policies.name_suffix}", "")
ospf_ipv4_address_family_context_policy = try("${vrf.ospf.ipv4_address_family_context_policy}${local.defaults.apic.tenants.policies.ospf_timer_policies.name_suffix}", "")
ospf_ipv6_address_family_context_policy = try("${vrf.ospf.ipv6_address_family_context_policy}${local.defaults.apic.tenants.policies.ospf_timer_policies.name_suffix}", "")
bgp_timer_policy = try("${vrf.bgp.timer_policy}${local.defaults.apic.tenants.policies.bgp_timer_policies.name_suffix}", "")
bgp_ipv4_address_family_context_policy = try("${vrf.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("${vrf.bgp.ipv6_address_family_context_policy}${local.defaults.apic.tenants.policies.bgp_address_family_context_policies.name_suffix}", "")
bgp_ipv4_import_route_target = try(vrf.bgp.ipv4_import_route_target, "")
bgp_ipv4_export_route_target = try(vrf.bgp.ipv4_export_route_target, "")
bgp_ipv6_import_route_target = try(vrf.bgp.ipv6_import_route_target, "")
bgp_ipv6_export_route_target = try(vrf.bgp.ipv6_export_route_target, "")
dns_labels = try(vrf.dns_labels, [])
pim_enabled = try(vrf.pim, null) != null ? true : false
pim_mtu = try(vrf.pim.mtu, local.defaults.apic.tenants.vrfs.pim.mtu)
pim_fast_convergence = try(vrf.pim.fast_convergence, local.defaults.apic.tenants.vrfs.pim.fast_convergence)
pim_strict_rfc = try(vrf.pim.strict_rfc, local.defaults.apic.tenants.vrfs.pim.strict_rfc)
pim_max_multicast_entries = try(vrf.pim.max_multicast_entries, local.defaults.apic.tenants.vrfs.pim.max_multicast_entries)
pim_reserved_multicast_entries = try(vrf.pim.reserved_multicast_entries, local.defaults.apic.tenants.vrfs.pim.reserved_multicast_entries)
pim_resource_policy_multicast_route_map = try(vrf.pim.resource_policy_multicast_route_map, null) != null ? "${vrf.pim.resource_policy_multicast_route_map}${local.defaults.apic.tenants.policies.multicast_route_maps.name_suffix}" : ""
pim_static_rps = [for rp in try(vrf.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(vrf.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(vrf.pim.bsr_listen_updates, local.defaults.apic.tenants.vrfs.pim.bsr_listen_updates)
pim_bsr_forward_updates = try(vrf.pim.bsr_forward_updates, local.defaults.apic.tenants.vrfs.pim.bsr_forward_updates)
pim_bsr_filter_multicast_route_map = try(vrf.pim.bsr_filter_multicast_route_map, null) != null ? "${vrf.pim.bsr_filter_multicast_route_map}${local.defaults.apic.tenants.policies.multicast_route_maps.name_suffix}" : ""
pim_auto_rp_listen_updates = try(vrf.pim.auto_rp_listen_updates, local.defaults.apic.tenants.vrfs.pim.auto_rp_listen_updates)
pim_auto_rp_forward_updates = try(vrf.pim.auto_rp_forward_updates, local.defaults.apic.tenants.vrfs.pim.auto_rp_forward_updates)
pim_auto_rp_filter_multicast_route_map = try(vrf.pim.auto_rp_filter_multicast_route_map, null) != null ? "${vrf.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(vrf.pim.asm_shared_range_multicast_route_map, null) != null ? "${vrf.pim.asm_shared_range_multicast_route_map}${local.defaults.apic.tenants.policies.multicast_route_maps.name_suffix}" : ""
pim_asm_sg_expiry = try(vrf.pim.asm_sg_expiry, local.defaults.apic.tenants.vrfs.pim.asm_sg_expiry)
pim_asm_sg_expiry_multicast_route_map = try(vrf.pim.asm_sg_expiry_multicast_route_map, null) != null ? "${vrf.pim.asm_sg_expiry_multicast_route_map}${local.defaults.apic.tenants.policies.multicast_route_maps.name_suffix}" : ""
pim_asm_traffic_registry_max_rate = try(vrf.pim.asm_traffic_registry_max_rate, local.defaults.apic.tenants.vrfs.pim.asm_traffic_registry_max_rate)
pim_asm_traffic_registry_source_ip = try(vrf.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(vrf.pim.ssm_group_range_multicast_route_map, null) != null ? "${vrf.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(vrf.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(vrf.pim.igmp_context_ssm_translate_policies, []) : {
group_prefix = pol.group_prefix
source_address = pol.source_address
}]
leaked_internal_prefixes = [for prefix in try(vrf.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(vrf.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
}]
}]
}
]
])
}
module "aci_vrf" {
source = "./modules/terraform-aci-vrf"
for_each = { for vrf in local.vrfs : vrf.key => vrf if local.modules.aci_vrf && var.manage_tenants }
tenant = each.value.tenant
name = each.value.name
annotation = each.value.annotation
alias = each.value.alias
description = each.value.description
enforcement_direction = each.value.enforcement_direction
enforcement_preference = each.value.enforcement_preference
data_plane_learning = each.value.data_plane_learning
contract_consumers = each.value.contract_consumers
contract_providers = each.value.contract_providers
contract_imported_consumers = each.value.contract_imported_consumers
preferred_group = each.value.preferred_group
transit_route_tag_policy = each.value.transit_route_tag_policy
ospf_timer_policy = each.value.ospf_timer_policy
ospf_ipv4_address_family_context_policy = each.value.ospf_ipv4_address_family_context_policy
ospf_ipv6_address_family_context_policy = each.value.ospf_ipv6_address_family_context_policy
bgp_timer_policy = each.value.bgp_timer_policy
bgp_ipv4_address_family_context_policy = each.value.bgp_ipv4_address_family_context_policy
bgp_ipv6_address_family_context_policy = each.value.bgp_ipv6_address_family_context_policy
bgp_ipv4_import_route_target = each.value.bgp_ipv4_import_route_target
bgp_ipv4_export_route_target = each.value.bgp_ipv4_export_route_target
bgp_ipv6_import_route_target = each.value.bgp_ipv6_import_route_target
bgp_ipv6_export_route_target = each.value.bgp_ipv6_export_route_target
dns_labels = each.value.dns_labels
pim_enabled = each.value.pim_enabled
pim_mtu = each.value.pim_mtu
pim_fast_convergence = each.value.pim_fast_convergence
pim_strict_rfc = each.value.pim_strict_rfc
pim_max_multicast_entries = each.value.pim_max_multicast_entries
pim_reserved_multicast_entries = each.value.pim_reserved_multicast_entries
pim_resource_policy_multicast_route_map = each.value.pim_resource_policy_multicast_route_map
pim_static_rps = each.value.pim_static_rps
pim_fabric_rps = each.value.pim_fabric_rps
pim_bsr_listen_updates = each.value.pim_bsr_listen_updates
pim_bsr_forward_updates = each.value.pim_bsr_forward_updates
pim_bsr_filter_multicast_route_map = each.value.pim_bsr_filter_multicast_route_map
pim_auto_rp_listen_updates = each.value.pim_auto_rp_listen_updates
pim_auto_rp_forward_updates = each.value.pim_auto_rp_forward_updates
pim_auto_rp_filter_multicast_route_map = each.value.pim_auto_rp_filter_multicast_route_map
pim_asm_shared_range_multicast_route_map = each.value.pim_asm_shared_range_multicast_route_map
pim_asm_sg_expiry = each.value.pim_asm_sg_expiry
pim_asm_sg_expiry_multicast_route_map = each.value.pim_asm_sg_expiry_multicast_route_map
pim_asm_traffic_registry_max_rate = each.value.pim_asm_traffic_registry_max_rate
pim_asm_traffic_registry_source_ip = each.value.pim_asm_traffic_registry_source_ip
pim_ssm_group_range_multicast_route_map = each.value.pim_ssm_group_range_multicast_route_map
pim_inter_vrf_policies = each.value.pim_inter_vrf_policies
pim_igmp_ssm_translate_policies = each.value.pim_igmp_ssm_translate_policies
leaked_internal_prefixes = each.value.leaked_internal_prefixes
leaked_external_prefixes = each.value.leaked_external_prefixes
depends_on = [
module.aci_tenant,
module.aci_contract,
module.aci_imported_contract,
module.aci_bgp_timer_policy,
]
}
locals {
bridge_domains = flatten([
for tenant in local.tenants : [
for bd in try(tenant.bridge_domains, []) : {
key = format("%s/%s", tenant.name, bd.name)
tenant = tenant.name
name = "${bd.name}${local.defaults.apic.tenants.bridge_domains.name_suffix}"
annotation = try(bd.ndo_managed, local.defaults.apic.tenants.bridge_domains.ndo_managed) ? "orchestrator:msc-shadow:no" : null
alias = try(bd.alias, "")
description = try(bd.description, "")
arp_flooding = try(bd.arp_flooding, local.defaults.apic.tenants.bridge_domains.arp_flooding)
advertise_host_routes = try(bd.advertise_host_routes, local.defaults.apic.tenants.bridge_domains.advertise_host_routes)
ip_dataplane_learning = try(bd.ip_dataplane_learning, local.defaults.apic.tenants.bridge_domains.ip_dataplane_learning)
limit_ip_learn_to_subnets = try(bd.limit_ip_learn_to_subnets, local.defaults.apic.tenants.bridge_domains.limit_ip_learn_to_subnets)
mac = try(bd.mac, local.defaults.apic.tenants.bridge_domains.mac)
virtual_mac = try(bd.virtual_mac, "not-applicable")
ep_move_detection = try(bd.ep_move_detection, local.defaults.apic.tenants.bridge_domains.ep_move_detection)
clear_remote_mac_entries = try(bd.clear_remote_mac_entries, local.defaults.apic.tenants.bridge_domains.clear_remote_mac_entries)
multicast_arp_drop = try(bd.multicast_arp_drop, null)
l3_multicast = try(bd.l3_multicast, local.defaults.apic.tenants.bridge_domains.l3_multicast)
pim_source_filter = try(bd.pim_source_filter, "")
pim_destination_filter = try(bd.pim_destination_filter, "")
multi_destination_flooding = try(bd.multi_destination_flooding, local.defaults.apic.tenants.bridge_domains.multi_destination_flooding)
unicast_routing = try(bd.unicast_routing, local.defaults.apic.tenants.bridge_domains.unicast_routing)
unknown_unicast = try(bd.unknown_unicast, local.defaults.apic.tenants.bridge_domains.unknown_unicast)
unknown_ipv4_multicast = try(bd.unknown_ipv4_multicast, local.defaults.apic.tenants.bridge_domains.unknown_ipv4_multicast)
unknown_ipv6_multicast = try(bd.unknown_ipv6_multicast, local.defaults.apic.tenants.bridge_domains.unknown_ipv6_multicast)
vrf = "${bd.vrf}${local.defaults.apic.tenants.vrfs.name_suffix}"
igmp_interface_policy = try("${bd.igmp_interface_policy}${local.defaults.apic.tenants.policies.igmp_interface_policies.name_suffix}", "")
igmp_snooping_policy = try("${bd.igmp_snooping_policy}${local.defaults.apic.tenants.policies.igmp_snooping_policies.name_suffix}", "")
nd_interface_policy = try("${bd.nd_interface_policy}${local.defaults.apic.tenants.policies.nd_interface_policies.name_suffix}", "")
subnets = [for subnet in try(bd.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)
nd_ra_prefix_policy = try("${subnet.nd_ra_prefix_policy}${local.defaults.apic.tenants.policies.nd_ra_prefix_policies.name_suffix}", "")
ip_dataplane_learning = try(subnet.ip_dataplane_learning, null)
}]
l3outs = try(bd.l3outs, null) != null ? [for l3out in bd.l3outs : "${l3out}${local.defaults.apic.tenants.l3outs.name_suffix}"] : []
dhcp_labels = [for label in try(bd.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}", "")
scope = try(label.scope, local.defaults.apic.tenants.bridge_domains.dhcp_labels.scope)
}]
}
]
])
}
module "aci_bridge_domain" {
source = "./modules/terraform-aci-bridge-domain"
for_each = { for bd in local.bridge_domains : bd.key => bd if local.modules.aci_bridge_domain && var.manage_tenants }
tenant = each.value.tenant
name = each.value.name
annotation = each.value.annotation
alias = each.value.alias
description = each.value.description
arp_flooding = each.value.arp_flooding
advertise_host_routes = each.value.advertise_host_routes
ip_dataplane_learning = each.value.ip_dataplane_learning
limit_ip_learn_to_subnets = each.value.limit_ip_learn_to_subnets
mac = each.value.mac
virtual_mac = each.value.virtual_mac
ep_move_detection = each.value.ep_move_detection
clear_remote_mac_entries = each.value.clear_remote_mac_entries
multicast_arp_drop = each.value.multicast_arp_drop
l3_multicast = each.value.l3_multicast
pim_source_filter = each.value.pim_source_filter
pim_destination_filter = each.value.pim_destination_filter
multi_destination_flooding = each.value.multi_destination_flooding
unicast_routing = each.value.unicast_routing
unknown_unicast = each.value.unknown_unicast
unknown_ipv4_multicast = each.value.unknown_ipv4_multicast
unknown_ipv6_multicast = each.value.unknown_ipv6_multicast
vrf = each.value.vrf
igmp_interface_policy = each.value.igmp_interface_policy
igmp_snooping_policy = each.value.igmp_snooping_policy
nd_interface_policy = each.value.nd_interface_policy
subnets = each.value.subnets
l3outs = each.value.l3outs
dhcp_labels = each.value.dhcp_labels
depends_on = [
module.aci_tenant,
module.aci_vrf,
module.aci_l3out,
module.aci_dhcp_relay_policy,
module.aci_dhcp_option_policy,
]
}
locals {
application_profiles = flatten([
for tenant in local.tenants : [
for ap in try(tenant.application_profiles, []) : {
key = format("%s/%s", tenant.name, ap.name)
tenant = tenant.name
name = "${ap.name}${local.defaults.apic.tenants.application_profiles.name_suffix}"
annotation = try(ap.ndo_managed, local.defaults.apic.tenants.application_profiles.ndo_managed) ? "orchestrator:msc-shadow:no" : null
alias = try(ap.alias, "")
description = try(ap.description, "")
} if try(ap.managed, local.defaults.apic.tenants.application_profiles.managed, true)
]
])
}
module "aci_application_profile" {
source = "./modules/terraform-aci-application-profile"
for_each = { for ap in local.application_profiles : ap.key => ap if local.modules.aci_application_profile && var.manage_tenants }
tenant = each.value.tenant
name = each.value.name
annotation = each.value.annotation
alias = each.value.alias
description = each.value.description
depends_on = [
module.aci_tenant
]
}
locals {
# first iteration to resolve node_id and determine IPG type for static ports
endpoint_groups = flatten([
for tenant in local.tenants : [
for ap in try(tenant.application_profiles, []) : [
for epg in try(ap.endpoint_groups, []) : {
key = format("%s/%s/%s", tenant.name, ap.name, epg.name)
tenant = tenant.name
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}"
annotation = try(epg.ndo_managed, local.defaults.apic.tenants.application_profiles.endpoint_groups.ndo_managed) ? "orchestrator:msc-shadow:no" : null
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)
proxy_arp = try(epg.proxy_arp, local.defaults.apic.tenants.application_profiles.endpoint_groups.proxy_arp)
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}"], [])
contract_masters = [for master in try(epg.contracts.masters, []) : {
endpoint_group = master.endpoint_group
application_profile = try(master.application_profile, "${ap.name}${local.defaults.apic.tenants.application_profiles.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)
nd_ra_prefix_policy = try("${subnet.nd_ra_prefix_policy}${local.defaults.apic.tenants.policies.nd_ra_prefix_policies.name_suffix}", "")
ip_dataplane_learning = try(subnet.ip_dataplane_learning, null)
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, "0.0.0.0")
end_ip = try(pool.end_ip, "0.0.0.0")
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"
description = try(sp.description, "")
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)
primary_vlan = try(sp.primary_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)
ptp_source_ip = try(sp.ptp.source_ip, local.defaults.apic.tenants.application_profiles.endpoint_groups.static_ports.ptp.source_ip)
ptp_mode = try(sp.ptp.mode, local.defaults.apic.tenants.application_profiles.endpoint_groups.static_ports.ptp.mode)
ptp_profile = try(sp.ptp.profile, null)
}]
static_leafs = [for sl in try(epg.static_leafs, []) : {
pod_id = try(sl.pod_id, null)
node_id = try(sl.node_id, null)
vlan = try(sl.vlan, null)
mode = try(sl.mode, local.defaults.apic.tenants.application_profiles.endpoint_groups.static_leafs.mode)
deployment_immediacy = try(sl.deployment_immediacy, local.defaults.apic.tenants.application_profiles.endpoint_groups.static_leafs.deployment_immediacy)
}]
static_endpoints = [for se in try(epg.static_endpoints, []) : {
name = try("${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, null)
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, "")
}]
}
]
]
])
}
module "aci_endpoint_group" {
source = "./modules/terraform-aci-endpoint-group"
for_each = { for epg in local.endpoint_groups : epg.key => epg if local.modules.aci_endpoint_group && var.manage_tenants }
bulk_static_ports = try(local.apic.bulk_static_ports, local.defaults.apic.bulk_static_ports)
tenant = each.value.tenant
application_profile = each.value.application_profile
name = each.value.name
annotation = each.value.annotation
alias = each.value.alias
description = each.value.description
flood_in_encap = each.value.flood_in_encap
intra_epg_isolation = each.value.intra_epg_isolation
proxy_arp = each.value.proxy_arp
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
contract_masters = each.value.contract_masters
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, []) : {
description = sp.description
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 = sp.pod_id == null ? try([for node in try(local.node_policies.nodes, []) : node.pod if node.id == sp.node_id][0], local.defaults.apic.node_policies.nodes.pod) : sp.pod_id
channel = sp.channel
port = sp.port
sub_port = sp.sub_port
module = sp.module
vlan = sp.vlan
primary_vlan = sp.primary_vlan
deployment_immediacy = sp.deployment_immediacy
mode = sp.mode
ptp_source_ip = sp.ptp_source_ip
ptp_mode = sp.ptp_mode
ptp_profile = sp.ptp_profile
}]
static_leafs = [for sl in try(each.value.static_leafs, []) : {
pod_id = sl.pod_id == null ? try([for node in try(local.node_policies.nodes, []) : node.pod if node.id == sl.node_id][0], local.defaults.apic.node_policies.nodes.pod) : sl.pod_id
node_id = sl.node_id
vlan = sl.vlan
mode = sl.mode
deployment_immediacy = sl.deployment_immediacy
}]
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 = se.pod_id == null ? try([for node in try(local.node_policies.nodes, []) : node.pod if node.id == se.node_id][0], local.defaults.apic.node_policies.nodes.pod) : se.pod_id
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 = [
module.aci_tenant,
module.aci_application_profile,
module.aci_bridge_domain,
module.aci_contract,
module.aci_imported_contract,
module.aci_vmware_vmm_domain,
module.aci_vlan_pool,
]
}
locals {
useg_endpoint_groups = flatten([
for tenant in local.tenants : [
for ap in try(tenant.application_profiles, []) : [
for useg_epg in try(ap.useg_endpoint_groups, []) : {
key = format("%s/%s/%s", tenant.name, ap.name, useg_epg.name)
tenant = tenant.name
application_profile = "${ap.name}${local.defaults.apic.tenants.application_profiles.name_suffix}"
name = "${useg_epg.name}${local.defaults.apic.tenants.application_profiles.useg_endpoint_groups.name_suffix}"
alias = try(useg_epg.alias, "")
description = try(useg_epg.description, "")
flood_in_encap = try(useg_epg.flood_in_encap, local.defaults.apic.tenants.application_profiles.useg_endpoint_groups.flood_in_encap)
intra_epg_isolation = try(useg_epg.intra_epg_isolation, local.defaults.apic.tenants.application_profiles.useg_endpoint_groups.intra_epg_isolation)
preferred_group = try(useg_epg.preferred_group, local.defaults.apic.tenants.application_profiles.useg_endpoint_groups.preferred_group)
qos_class = try(useg_epg.qos_class, local.defaults.apic.tenants.application_profiles.useg_endpoint_groups.qos_class)
custom_qos_policy = try("${useg_epg.custom_qos_policy}${local.defaults.apic.tenants.policies.custom_qos.name_suffix}", "")
bridge_domain = try("${useg_epg.bridge_domain}${local.defaults.apic.tenants.bridge_domains.name_suffix}", "")
tags = try(useg_epg.tags, [])
trust_control_policy = try("${useg_epg.trust_control_policy}${local.defaults.apic.tenants.policies.trust_control_policies.name_suffix}", "")
contract_consumers = try([for contract in useg_epg.contracts.consumers : "${contract}${local.defaults.apic.tenants.contracts.name_suffix}"], [])
contract_providers = try([for contract in useg_epg.contracts.providers : "${contract}${local.defaults.apic.tenants.contracts.name_suffix}"], [])
contract_imported_consumers = try([for contract in useg_epg.contracts.imported_consumers : "${contract}${local.defaults.apic.tenants.imported_contracts.name_suffix}"], [])
contract_intra_epgs = try([for contract in useg_epg.contracts.intra_epgs : "${contract}${local.defaults.apic.tenants.contracts.name_suffix}"], [])
physical_domains = try([for domain in useg_epg.physical_domains : "${domain}${local.defaults.apic.access_policies.physical_domains.name_suffix}"], [])
useg_attributes_match_type = try(useg_epg.useg_attributes.match_type, local.defaults.apic.tenants.application_profiles.useg_endpoint_groups.useg_attributes.match_type)
contract_masters = [for master in try(useg_epg.contracts.masters, []) : {
endpoint_group = master.endpoint_group
application_profile = try(master.application_profile, "${ap.name}${local.defaults.apic.tenants.application_profiles.name_suffix}")
}]
useg_attributes_ip_statements = [for ip_statement in try(useg_epg.useg_attributes.ip_statements, []) : {
name = ip_statement.name
use_epg_subnet = try(ip_statement.use_epg_subnet, local.defaults.apic.tenants.application_profiles.useg_endpoint_groups.useg_attributes.ip_statements.use_epg_subnet)
ip = try(ip_statement.ip, "")
}]
useg_attributes_mac_statements = [for mac_statement in try(useg_epg.useg_attributes.mac_statements, []) : {
name = mac_statement.name
mac = upper(mac_statement.mac)
}]
subnets = [for subnet in try(useg_epg.subnets, []) : {
description = try(subnet.description, "")
ip = subnet.ip
public = try(subnet.public, local.defaults.apic.tenants.application_profiles.useg_endpoint_groups.subnets.public)
shared = try(subnet.shared, local.defaults.apic.tenants.application_profiles.useg_endpoint_groups.subnets.shared)
igmp_querier = try(subnet.igmp_querier, local.defaults.apic.tenants.application_profiles.useg_endpoint_groups.subnets.igmp_querier)
nd_ra_prefix = try(subnet.nd_ra_prefix, local.defaults.apic.tenants.application_profiles.useg_endpoint_groups.subnets.nd_ra_prefix)
no_default_gateway = try(subnet.no_default_gateway, local.defaults.apic.tenants.application_profiles.useg_endpoint_groups.subnets.no_default_gateway)
nd_ra_prefix_policy = try("${subnet.nd_ra_prefix_policy}${local.defaults.apic.tenants.policies.nd_ra_prefix_policies.name_suffix}", "")
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.useg_endpoint_groups.subnets.ip_pools.name_suffix}"
start_ip = try(pool.start_ip, "0.0.0.0")
end_ip = try(pool.end_ip, "0.0.0.0")
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(useg_epg.vmware_vmm_domains, []) : {
name = "${vmm.name}${local.defaults.apic.fabric_policies.vmware_vmm_domains.name_suffix}"
deployment_immediacy = try(vmm.deployment_immediacy, local.defaults.apic.tenants.application_profiles.useg_endpoint_groups.vmware_vmm_domains.deployment_immediacy)
netflow = try(vmm.netflow, local.defaults.apic.tenants.application_profiles.useg_endpoint_groups.vmware_vmm_domains.netflow)
elag = try(vmm.elag, "")
active_uplinks_order = try(vmm.active_uplinks_order, "")
standby_uplinks = try(vmm.standby_uplinks, "")
}]
static_leafs = [for sl in try(useg_epg.static_leafs, []) : {
pod_id = try(sl.pod_id, null)
node_id = try(sl.node_id, null)
}]
l4l7_address_pools = [for ap in try(useg_epg.l4l7_address_pools, []) : {
name = ap.name
gateway_address = ap.gateway_address
from = try(ap.from, "")
to = try(ap.to, "")
}]
}
]
]
])
}
module "aci_useg_endpoint_group" {
source = "./modules/terraform-aci-useg-endpoint-group"
for_each = { for epg in local.useg_endpoint_groups : epg.key => epg if local.modules.aci_useg_endpoint_group && var.manage_tenants }
tenant = each.value.tenant
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
contract_masters = each.value.contract_masters
physical_domains = each.value.physical_domains
match_type = each.value.useg_attributes_match_type
ip_statements = each.value.useg_attributes_ip_statements
mac_statements = each.value.useg_attributes_mac_statements
subnets = each.value.subnets
vmware_vmm_domains = each.value.vmware_vmm_domains
static_leafs = [for sl in try(each.value.static_leafs, []) : {
pod_id = sl.pod_id == null ? try([for node in try(local.node_policies.nodes, []) : node.pod if node.id == sl.node_id][0], local.defaults.apic.node_policies.nodes.pod) : sl.pod_id
node_id = sl.node_id
}]
l4l7_address_pools = each.value.l4l7_address_pools
depends_on = [
module.aci_tenant,
module.aci_application_profile,
module.aci_endpoint_group,
module.aci_bridge_domain,
module.aci_contract,
module.aci_imported_contract,
module.aci_vmware_vmm_domain,
]
}
locals {
endpoint_security_groups = flatten([
for tenant in local.tenants : [
for ap in try(tenant.application_profiles, []) : [
for esg in try(ap.endpoint_security_groups, []) : {
key = format("%s/%s/%s", tenant.name, ap.name, esg.name)
tenant = tenant.name
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 = 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 = 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, "")
}]
}
]
]
])
}
module "aci_endpoint_security_group" {
source = "./modules/terraform-aci-endpoint-security-group"
for_each = { for esg in local.endpoint_security_groups : esg.key => esg if local.modules.aci_endpoint_security_group && var.manage_tenants }
tenant = each.value.tenant
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 = [
module.aci_tenant,
module.aci_application_profile,
module.aci_vrf,
module.aci_contract,
module.aci_endpoint_group,
]
}
locals {
inband_endpoint_groups = flatten([
for tenant in local.tenants : [
for epg in try(tenant.inb_endpoint_groups, []) : {
key = format("%s/%s", tenant.name, epg.name)
name = "${epg.name}${local.defaults.apic.tenants.inb_endpoint_groups.name_suffix}"
vlan = epg.vlan
bridge_domain = "${epg.bridge_domain}${local.defaults.apic.tenants.bridge_domains.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}"], [])
static_routes = try(epg.static_routes, [])
}
] if tenant.name == "mgmt"
])
}
module "aci_inband_endpoint_group" {
source = "./modules/terraform-aci-inband-endpoint-group"
for_each = { for epg in local.inband_endpoint_groups : epg.key => epg if local.modules.aci_inband_endpoint_group && var.manage_tenants }
name = each.value.name
vlan = each.value.vlan
bridge_domain = each.value.bridge_domain
contract_consumers = each.value.contract_consumers
contract_providers = each.value.contract_providers
contract_imported_consumers = each.value.contract_imported_consumers
static_routes = each.value.static_routes
depends_on = [
module.aci_tenant,
module.aci_contract,
module.aci_imported_contract,
module.aci_bridge_domain,
]
}
locals {
oob_endpoint_groups = flatten([
for tenant in local.tenants : [
for epg in try(tenant.oob_endpoint_groups, []) : {
key = format("%s/%s", tenant.name, epg.name)
name = "${epg.name}${local.defaults.apic.tenants.oob_endpoint_groups.name_suffix}"
oob_contract_providers = try([for contract in epg.oob_contracts.providers : "${contract}${local.defaults.apic.tenants.oob_contracts.name_suffix}"], [])
static_routes = try(epg.static_routes, [])
}
] if tenant.name == "mgmt"
])
}
module "aci_oob_endpoint_group" {
source = "./modules/terraform-aci-oob-endpoint-group"
for_each = { for epg in local.oob_endpoint_groups : epg.key => epg if local.modules.aci_oob_endpoint_group && var.manage_tenants }
name = each.value.name
oob_contract_providers = each.value.oob_contract_providers
static_routes = each.value.static_routes
depends_on = [
module.aci_tenant,
module.aci_oob_contract,
]
}
locals {
external_management_instances = flatten([
for tenant in local.tenants : [
for ext in try(tenant.ext_mgmt_instances, []) : {
key = format("%s/%s", tenant.name, ext.name)
name = "${ext.name}${local.defaults.apic.tenants.ext_mgmt_instances.name_suffix}"
subnets = try(ext.subnets, [])
oob_contract_consumers = try([for contract in ext.oob_contracts.consumers : "${contract}${local.defaults.apic.tenants.oob_contracts.name_suffix}"], [])
}
] if tenant.name == "mgmt"
])
}
module "aci_oob_external_management_instance" {
source = "./modules/terraform-aci-oob-external-management-instance"
for_each = { for ext in local.external_management_instances : ext.key => ext if local.modules.aci_oob_external_management_instance && var.manage_tenants }
name = each.value.name
subnets = each.value.subnets
oob_contract_consumers = each.value.oob_contract_consumers
depends_on = [
module.aci_tenant,
module.aci_oob_contract,
]
}
locals {
l3outs = flatten([
for tenant in local.tenants : [
for l3out in try(tenant.l3outs, []) : {
key = format("%s/%s", tenant.name, l3out.name)
tenant = tenant.name
name = "${l3out.name}${local.defaults.apic.tenants.l3outs.name_suffix}"
annotation = try(l3out.ndo_managed, local.defaults.apic.tenants.l3outs.ndo_managed) ? "orchestrator:msc-shadow:no" : null
alias = try(l3out.alias, "")
description = try(l3out.description, "")
multipod = try(l3out.multipod, local.defaults.apic.tenants.l3outs.multipod)
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" : 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)
ospf_area_control_redistribute = try(l3out.ospf.area_control_redistribute, local.defaults.apic.tenants.l3outs.ospf.area_control_redistribute)
ospf_area_control_summary = try(l3out.ospf.area_control_summary, local.defaults.apic.tenants.l3outs.ospf.area_control_summary)
ospf_area_control_suppress_fa = try(l3out.ospf.area_control_suppress_fa, local.defaults.apic.tenants.l3outs.ospf.area_control_suppress_fa)
eigrp = try(l3out.eigrp, null) != null ? true : false
eigrp_asn = try(l3out.eigrp, null) != null ? l3out.eigrp.asn : 1
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)
import_route_control_enforcement = try(l3out.import_route_control_enforcement, local.defaults.apic.tenants.l3outs.import_route_control_enforcement)
export_route_control_enforcement = try(l3out.export_route_control_enforcement, local.defaults.apic.tenants.l3outs.export_route_control_enforcement)
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_name = try(l3out.import_route_map.name, "default-import")
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_rules = [for rule in try(context.match_rules, []) : "${rule}${local.defaults.apic.tenants.policies.match_rules.name_suffix}"]
}]
export_route_map_name = try(l3out.export_route_map.name, "default-export")
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_rules = [for rule in try(context.match_rules, []) : "${rule}${local.defaults.apic.tenants.policies.match_rules.name_suffix}"]
}]
}
]
])
}
module "aci_l3out" {
source = "./modules/terraform-aci-l3out"
for_each = { for l3out in local.l3outs : l3out.key => l3out if local.modules.aci_l3out && var.manage_tenants }
tenant = each.value.tenant
name = each.value.name
annotation = each.value.annotation
alias = each.value.alias
description = each.value.description
multipod = each.value.multipod
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
ospf_area_control_redistribute = each.value.ospf_area_control_redistribute
ospf_area_control_summary = each.value.ospf_area_control_summary
ospf_area_control_suppress_fa = each.value.ospf_area_control_suppress_fa
eigrp = each.value.eigrp
eigrp_asn = each.value.eigrp_asn
l3_multicast_ipv4 = each.value.l3_multicast_ipv4
target_dscp = each.value.target_dscp
import_route_control_enforcement = each.value.import_route_control_enforcement
export_route_control_enforcement = each.value.export_route_control_enforcement
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_name = each.value.import_route_map_name
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_name = each.value.export_route_map_name
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 = [
module.aci_tenant,
module.aci_vrf,
module.aci_ospf_interface_policy,
module.aci_eigrp_interface_policy,
module.aci_bfd_interface_policy,
module.aci_set_rule,
module.aci_match_rule,
]
}
locals {
node_profiles_manual = flatten([
for tenant in local.tenants : [
for l3out in try(tenant.l3outs, []) : [
for np in try(l3out.node_profiles, []) : {
key = format("%s/%s/%s", tenant.name, l3out.name, np.name)
tenant = tenant.name
l3out = l3out.name
name = "${np.name}${local.defaults.apic.tenants.l3outs.node_profiles.name_suffix}"
multipod = try(l3out.multipod, local.defaults.apic.tenants.l3outs.multipod)
remote_leaf = try(l3out.remote_leaf, local.defaults.apic.tenants.l3outs.remote_leaf)
bgp_timer_policy = try("${np.bgp.timer_policy}${local.defaults.apic.tenants.policies.bgp_timer_policies.name_suffix}", "")
bgp_as_path_policy = try("${np.bgp.as_path_policy}${local.defaults.apic.tenants.policies.bgp_best_path_policies.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)
track_list = try(sr.track_list, null)
next_hops = [for nh in try(sr.next_hops, []) : {
ip = nh.ip
description = try(nh.description, "")
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)