-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.tf
212 lines (194 loc) · 8.83 KB
/
variables.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
variable "device" {
description = "A device name from the provider configuration."
type = string
default = null
}
variable "name" {
description = "OSPF Process Name."
type = string
validation {
condition = can(regex("^[a-zA-Z0-9_.-]{0,32}$", var.name))
error_message = "Allowed characters: `a`-`z`, `A`-`Z`, `0`-`9`, `_`, `-`. Maximum characters: 20."
}
}
variable "vrfs" {
description = <<EOT
OSPF VRF list.
Default value `admin_state`: `true`.
Default value `bandwidth_reference`: `40000`.
Choices `bandwidth_reference_unit`: `mbps`, `gbps`. Default value `bandwidth_reference_unit`: `mbps`.
Default value `distance`: `110`.
List `areas`:
Allowed formats `area`: `0.0.0.10`. Default value `area`: `0.0.0.0`.
Choices `authentication_type`: `unspecified`, `simple`, `md5`, `none`. Default value `authentication_type`: `unspecified`.
Default value `cost`: `110`.
List `interfaces`:
Default value `advertise_secondaries`: `true`.
Allowed formats `area`: `0.0.0.10`. Default value `area`: `0.0.0.0`.
Default value `advertise_secondaries`: `true`.
Choices `bfd`: `unspecified`, `enabled`, `disabled`. Default value `bfd`: `unspecified`.
Default value `cost`: `0`.
Default value `dead_interval`: `0`.
Default value `hello_interval`: `10`.
Choices `network_type`: `unspecified`, `p2p`, `bcast`. Default value `network_type`: `unspecified`.
Choices `passive`: `unspecified`, `enabled`, `disabled`. Default value `passive`: `unspecified`.
Default value `priority`: `1`.
Allowed formats `authentication_key`: '0 <unencrypted-key>', '3 <3DES-format-encrypted-key>', '7 <Cisco-type-encrypted-key>'. Default value `area`: `0.0.0.0`.
Default value `authentication_key_id`: `0`.
Default value `authentication_key_secure_mode`: `false`.
Default value `authentication_md5_key_secure_mode`: `false`.
Choices `authentication_type`: `unspecified`, `simple`, `md5`, `none`. Default value `authentication_type`: `unspecified`.
EOT
type = list(object({
vrf = string
admin_state = optional(bool, true)
bandwidth_reference = optional(number, 40000)
bandwidth_reference_unit = optional(string, "mbps")
distance = optional(number, 110)
router_id = optional(string, "0.0.0.0")
# adjancency_logging_level = optional(string)
areas = optional(list(object({
area = string
authentication_type = optional(string, "unspecified")
cost = optional(number, 1)
type = optional(string, "regular")
})))
interfaces = optional(list(object({
interface = string
advertise_secondaries = optional(bool, true)
area = optional(string, "0.0.0.0")
bfd = optional(string, "unspecified")
cost = optional(number, 0)
dead_interval = optional(number, 0)
hello_interval = optional(number, 10)
network_type = optional(string, "unspecified")
passive = optional(string, "unspecified")
priority = optional(number, 1)
authentication_key = optional(string)
authentication_key_id = optional(number, 0)
authentication_key_secure_mode = optional(bool, false)
authentication_keychain = optional(string)
authentication_md5_key = optional(string)
authentication_md5_key_secure_mode = optional(bool, false)
authentication_type = optional(string)
})))
}))
default = []
validation {
condition = alltrue([
for v in var.vrfs : try(contains(["mbps", "gbps"], v.bandwidth_reference_unit), v.bandwidth_reference_unit == null)
])
error_message = "`bandwidth_reference_unit`: Allowed values are: `mbps` or `gbps`."
}
validation {
condition = alltrue([
for v in var.vrfs : can(regex("^\\d+\\.\\d+\\.\\d+\\.\\d+$", v.router_id)) || v.router_id == null
])
error_message = "`router_id`: Allowed formats are: `192.168.1.1`."
}
validation {
condition = alltrue(flatten([
for value in var.vrfs : value.areas == null ? [true] : [
for v in value.areas : can(regex("^\\d+\\.\\d+\\.\\d+\\.\\d+$", v.area)) || v.area == null
]
]))
error_message = "`areas - area`: Allowed formats are: `0.0.0.10`."
}
validation {
condition = alltrue(flatten([
for value in var.vrfs : value.areas == null ? [true] : [
for v in value.areas : try(contains(["unspecified", "simple", "md5", "none"], v.authentication_type), v.authentication_type == null)
]
]))
error_message = "`areas - authentication_type`: Allowed values are: `unspecified`, `simple`, `md5` or `none`."
}
validation {
condition = alltrue(flatten([
for value in var.vrfs : value.interfaces == null ? [true] : [
for v in value.interfaces : can(regex("^\\d+\\.\\d+\\.\\d+\\.\\d+$", v.area)) || v.area == null
]
]))
error_message = "`interfaces - area`: Allowed formats are: `0.0.0.10`."
}
validation {
condition = alltrue(flatten([
for value in var.vrfs : value.interfaces == null ? [true] : [
for v in value.interfaces : try(contains(["unspecified", "enabled", "disabled"], v.bfd), v.bfd == null)
]
]))
error_message = "`interfaces - bfd`: Allowed values are: `unspecified`, `enabled` or `disabled`."
}
validation {
condition = alltrue(flatten([
for value in var.vrfs : value.interfaces == null ? [true] : [
for v in value.interfaces : try(v.cost >= 0 && v.cost <= 3600, v.cost == null)
]
]))
error_message = "`interfaces - cost`: Minimum value: `0`. Maximum value: `65535`."
}
validation {
condition = alltrue(flatten([
for value in var.vrfs : value.interfaces == null ? [true] : [
for v in value.interfaces : try(v.dead_interval >= 0 && v.dead_interval <= 3600, v.dead_interval == null)
]
]))
error_message = "`interfaces - dead_interval`: Minimum value: `0`. Maximum value: `65535`."
}
validation {
condition = alltrue(flatten([
for value in var.vrfs : value.interfaces == null ? [true] : [
for v in value.interfaces : try(v.hello_interval >= 0 && v.hello_interval <= 3600, v.hello_interval == null)
]
]))
error_message = "`interfaces - hello_interval`: Minimum value: `0`. Maximum value: `65535`."
}
validation {
condition = alltrue(flatten([
for value in var.vrfs : value.interfaces == null ? [true] : [
for v in value.interfaces : try(contains(["unspecified", "p2p", "bcast"], v.network_type), v.network_type == null)
]
]))
error_message = "`interfaces - network_type`: Allowed values are: `unspecified`, `p2p` or `bcast`."
}
validation {
condition = alltrue(flatten([
for value in var.vrfs : value.interfaces == null ? [true] : [
for v in value.interfaces : try(contains(["unspecified", "enabled", "disabled"], v.passive), v.passive == null)
]
]))
error_message = "`interfaces - passive`: Allowed values are: `unspecified`, `enabled` or `disabled`."
}
validation {
condition = alltrue(flatten([
for value in var.vrfs : value.interfaces == null ? [true] : [
for v in value.interfaces : try(v.priority >= 0 && v.priority <= 255, v.priority == null)
]
]))
error_message = "`interfaces - priority`: Minimum value: `0`. Maximum value: `255`."
}
validation {
condition = alltrue(flatten([
for value in var.vrfs : value.interfaces == null ? [true] : [
for v in value.interfaces : can(regex("^[037] \\S+$", v.authentication_key)) || v.authentication_key == null
# || can(regex("^3 \\S+$", v.authentication_key)) || can(regex("^7 \\S+$", v.authentication_key)) ||
]
]))
error_message = "`interfaces - authentication_key`: Allowed formats are: '0 <unencrypted-key>', '3 <3DES-format-encrypted-key>', '7 <Cisco-type-encrypted-key>'."
}
validation {
condition = alltrue(flatten([
for value in var.vrfs : value.interfaces == null ? [true] : [
for v in value.interfaces : try(v.authentication_key_id >= 0 && v.authentication_key_id <= 255, v.authentication_key_id == null)
]
]))
error_message = "`interfaces - authentication_key_id`: Minimum value: `0`. Maximum value: `255`."
}
validation {
condition = alltrue(flatten([
for value in var.vrfs : value.interfaces == null ? [true] : [
for v in value.interfaces : try(contains(["unspecified", "simple", "md5", "none"], v.authentication_type), v.authentication_type == null)
]
]))
error_message = "`interfaces - authentication_type`: Allowed values are: `unspecified`, `simple`, `md5` or `none`."
}
}