-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
134 lines (119 loc) · 4.6 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
#__________________________________________________________________
#
# Tenant Settings Sensitive Variables
#__________________________________________________________________
data "utils_yaml_merge" "model" {
input = concat(
[for file in fileset(path.module, "*eza.yaml") : file(file)],
[for file in fileset(path.module, "*/*eza.yaml") : file(file)]
)
merge_list_items = false
}
#__________________________________________________________________
#
# ACCESS MODULE
#__________________________________________________________________
module "access" {
depends_on = [module.system_settings]
source = "terraform-cisco-modules/access/aci"
version = "3.1.10"
for_each = { for v in ["default"] : v => v if length(
lookup(local.model, "access", {})) > 0 || length(lookup(local.model, "virtual_networking", {})) > 0
}
access = merge(
lookup(local.model, "access", {}),
{ global_settings = local.global_settings },
lookup(local.model, "virtual_networking", {})
)
access_sensitive = local.access_sensitive
}
#__________________________________________________________________
#
# ADMIN MODULE
#__________________________________________________________________
module "admin" {
depends_on = [module.built_in_tenants]
source = "terraform-cisco-modules/admin/aci"
version = "3.1.10"
for_each = { for v in ["default"] : v => v if length(lookup(local.model, "admin", {})) > 0 }
admin = merge(lookup(local.model, "admin", {}), { global_settings = local.global_settings })
admin_sensitive = local.admin_sensitive
}
#__________________________________________________________________
#
# BUILT-IN TENANTS MODULE
#__________________________________________________________________
module "built_in_tenants" {
depends_on = [module.access]
source = "terraform-cisco-modules/tenants/aci"
version = "3.1.10"
for_each = {
for v in lookup(local.model, "tenants", []) : v.name => v if length(regexall("^(common|infra|mgmt)$", v.name)) > 0
}
model = merge(each.value, {
aaep_to_epgs = local.aaep_to_epgs
global_settings = local.global_settings
switch = lookup(local.model, "switch", {})
templates = lookup(local.model, "templates", {})
})
tenant = each.key
tenant_sensitive = local.tenant_sensitive
}
#__________________________________________________________________
#
# FABRIC MODULE
#__________________________________________________________________
module "fabric" {
depends_on = [module.built_in_tenants]
source = "terraform-cisco-modules/fabric/aci"
version = "3.1.10"
for_each = { for v in ["default"] : v => v if length(lookup(local.model, "fabric", {})) > 0 }
fabric = merge(local.model.fabric, { global_settings = local.global_settings })
fabric_sensitive = local.fabric_sensitive
}
#__________________________________________________________________
#
# SWITCH MODULE
#__________________________________________________________________
module "switch" {
depends_on = [module.built_in_tenants]
source = "terraform-cisco-modules/switch/aci"
version = "3.1.10"
for_each = { for v in ["default"] : v => v if length(
lookup(local.model, "switch", {})) > 0 && local.global_settings.controller.type == "apic"
}
switch = local.model.switch
}
#__________________________________________________________________
#
# SYSTEM SETTINGS MODULE
#__________________________________________________________________
module "system_settings" {
source = "terraform-cisco-modules/system-settings/aci"
version = "3.1.10"
for_each = {
for v in ["default"] : v => v if length(lookup(local.model, "system_settings", {})
) > 0 && local.global_settings.controller.type == "apic" }
system_sensitive = local.system_sensitive
system_settings = merge(local.model.system_settings, { global_settings = local.global_settings })
}
#__________________________________________________________________
#
# TENANTS MODULE
#__________________________________________________________________
module "tenants" {
depends_on = [module.built_in_tenants]
source = "terraform-cisco-modules/tenants/aci"
version = "3.1.10"
for_each = {
for v in lookup(local.model, "tenants", []) : v.name => v if length(regexall("^(common|infra|mgmt)$", v.name)) == 0
}
model = merge(each.value, {
aaep_to_epgs = local.aaep_to_epgs
global_settings = local.global_settings
switch = lookup(local.model, "switch", {})
templates = lookup(local.model, "templates", {})
})
tenant = each.key
tenant_sensitive = local.tenant_sensitive
}