-
Notifications
You must be signed in to change notification settings - Fork 2
/
variables.tf
306 lines (287 loc) · 10.8 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
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
variable "name" {
description = "Virtual network name"
type = string
}
variable "resource_group_name" {
description = "Virtual network resource group name"
type = string
}
variable "location" {
description = "Virtual network region"
type = string
# Use this Azure CLI command to refresh the list of regions:
# az account list-locations --query "[].name" --output tsv | sort | awk -F, -v OFS='","' -v q='"' '{$1=$1; print q $0 q}' | awk '{printf "%s%s",sep,$0; sep=",\n"} END{print ""}'
validation {
condition = contains([
"asia",
"asiapacific",
"australia",
"australiacentral",
"australiacentral2",
"australiaeast",
"australiasoutheast",
"brazil",
"brazilsouth",
"brazilsoutheast",
"brazilus",
"canada",
"canadacentral",
"canadaeast",
"centralindia",
"centralus",
"centraluseuap",
"centralusstage",
"eastasia",
"eastasiastage",
"eastus",
"eastus2",
"eastus2euap",
"eastus2stage",
"eastusstage",
"eastusstg",
"europe",
"france",
"francecentral",
"francesouth",
"germany",
"germanynorth",
"germanywestcentral",
"global",
"india",
"israelcentral",
"italynorth",
"japan",
"japaneast",
"japanwest",
"jioindiacentral",
"jioindiawest",
"korea",
"koreacentral",
"koreasouth",
"northcentralus",
"northcentralusstage",
"northeurope",
"norway",
"norwayeast",
"norwaywest",
"polandcentral",
"qatarcentral",
"singapore",
"southafrica",
"southafricanorth",
"southafricawest",
"southcentralus",
"southcentralusstage",
"southeastasia",
"southeastasiastage",
"southindia",
"sweden",
"swedencentral",
"switzerland",
"switzerlandnorth",
"switzerlandwest",
"uae",
"uaecentral",
"uaenorth",
"uk",
"uksouth",
"ukwest",
"unitedstates",
"unitedstateseuap",
"westcentralus",
"westeurope",
"westindia",
"westus",
"westus2",
"westus2stage",
"westus3",
"westusstage"
], var.location)
error_message = "Location must be a valid Azure region."
}
}
variable "address_space" {
default = ["10.0.0.0/16"]
description = "Virtual network address space."
type = list(string)
validation {
condition = alltrue([for i in var.address_space : can(cidrhost(i, 1))])
error_message = "Each address_space element must be a provided in proper CIDR notation."
}
}
variable "bgp_community" {
default = null
description = "BGP community attribute."
type = string
}
variable "ddos_protection_plan_id" {
default = null
description = "DDoS protection plan ID."
type = string
}
variable "dns_servers" {
default = []
description = "Virtual network DNS server IP addresses."
type = list(string)
}
variable "edge_zone" {
default = null
description = "Virtual network edge zone."
type = string
}
variable "flow_timeout_in_minutes" {
default = null
description = "Flow timeout in minutes."
type = number
validation {
condition = var.flow_timeout_in_minutes == null ? true : var.flow_timeout_in_minutes >= 4 && var.flow_timeout_in_minutes <= 30
error_message = "flow_timeout_in_minutes value must be between 4 and 30 minutes."
}
}
variable "encryption" {
default = null
description = "Virtual network encryption enforcement."
type = string
validation {
condition = var.encryption == null ? true : contains(["DropUnencrypted", "AllowUnencrypted"], var.encryption)
error_message = "Encryption must be either 'DropUnencrypted' or 'AllowUnencrypted'."
}
}
variable "subnets" {
default = {}
description = "Subnet map with the key as the subnet name."
type = map(object({
address_prefixes = list(string)
private_endpoint_network_policies_enabled = optional(bool, true)
private_link_service_network_policies_enabled = optional(bool, true)
service_endpoints = optional(list(string), [])
service_endpoint_policy_ids = optional(list(string), null)
delegation = optional(map(object({
service_name = string
actions = list(string)
})), {})
}))
validation {
condition = alltrue(flatten([for k, v in var.subnets : [
for address_prefix in v.address_prefixes : can(cidrhost(address_prefix, 1))
]]))
error_message = "Each subnet address_prefix must be a provided in proper CIDR notation."
}
# Use this Azure CLI command to refresh the list of service endpoints:
# locations=$(az account list-locations --query "[].name" --output tsv) && for location in $locations; do az network vnet list-endpoint-services --location eastus --query "[].name" --output tsv 2>/dev/null; done | sort | uniq | awk -F, -v OFS='","' -v q='"' '{$1=$1; print q $0 q}' | awk '{printf "%s%s",sep,$0; sep=",\n"} END{print ""}'
validation {
condition = alltrue(flatten([for k, v in var.subnets : [
for service_endpoint in v.service_endpoints : contains([
"Microsoft.AzureActiveDirectory",
"Microsoft.AzureCosmosDB",
"Microsoft.CognitiveServices",
"Microsoft.ContainerRegistry",
"Microsoft.EventHub",
"Microsoft.KeyVault",
"Microsoft.ServiceBus",
"Microsoft.Sql",
"Microsoft.Storage",
"Microsoft.Storage.Global",
"Microsoft.Web"
], service_endpoint)
]]))
error_message = "Service endpoints must be one of the supported Azure service types."
}
# Use this Azure CLI command to refresh the list of available service delegations:
# locations=$(az account list-locations --query "[].name" --output tsv) && for location in $locations; do az network vnet subnet list-available-delegations --query "[].serviceName" --location $location --output tsv 2>/dev/null; done | sort | uniq | awk -F, -v OFS='","' -v q='"' '{$1=$1; print q $0 q}' | awk '{printf "%s%s",sep,$0; sep=",\n"} END{print ""}'
validation {
condition = alltrue(flatten([for k, v in var.subnets : [
for dk, dv in v.delegation : contains([
"Dell.Storage/fileSystems",
"GitHub.Network/networkSettings",
"Informatica.DataManagement/organizations",
"Microsoft.AVS/PrivateClouds",
"Microsoft.ApiManagement/service",
"Microsoft.Apollo/npu",
"Microsoft.App/environments",
"Microsoft.App/testClients",
"Microsoft.AzureCommunicationsGateway/networkSettings",
"Microsoft.AzureCosmosDB/clusters",
"Microsoft.BareMetal/AzureHostedService",
"Microsoft.BareMetal/AzureVMware",
"Microsoft.BareMetal/CrayServers",
"Microsoft.Batch/batchAccounts",
"Microsoft.CloudTest/hostedpools",
"Microsoft.CloudTest/images",
"Microsoft.CloudTest/pools",
"Microsoft.Codespaces/plans",
"Microsoft.ContainerInstance/containerGroups",
"Microsoft.ContainerService/managedClusters",
"Microsoft.DBforMySQL/flexibleServers",
"Microsoft.DBforMySQL/servers",
"Microsoft.DBforMySQL/serversv2",
"Microsoft.DBforPostgreSQL/flexibleServers",
"Microsoft.DBforPostgreSQL/serversv2",
"Microsoft.DBforPostgreSQL/singleServers",
"Microsoft.Databricks/workspaces",
"Microsoft.DelegatedNetwork/controller",
"Microsoft.DevCenter/networkConnection",
"Microsoft.DevOpsInfrastructure/pools",
"Microsoft.DocumentDB/cassandraClusters",
"Microsoft.Fidalgo/networkSettings",
"Microsoft.HardwareSecurityModules/dedicatedHSMs",
"Microsoft.Kusto/clusters",
"Microsoft.LabServices/labplans",
"Microsoft.Logic/integrationServiceEnvironments",
"Microsoft.MachineLearningServices/workspaceComputes",
"Microsoft.MachineLearningServices/workspaces",
"Microsoft.Netapp/scaleVolumes",
"Microsoft.Netapp/volumes",
"Microsoft.Network/dnsResolvers",
"Microsoft.Network/networkWatchers",
"Microsoft.Orbital/orbitalGateways",
"Microsoft.PowerAutomate/hostedRpa",
"Microsoft.PowerPlatform/enterprisePolicies",
"Microsoft.PowerPlatform/vnetaccesslinks",
"Microsoft.ServiceFabricMesh/networks",
"Microsoft.ServiceNetworking/trafficControllers",
"Microsoft.Singularity/accounts/networks",
"Microsoft.Singularity/accounts/npu",
"Microsoft.Sql/managedInstances",
"Microsoft.StoragePool/diskPools",
"Microsoft.StreamAnalytics/streamingJobs",
"Microsoft.Synapse/workspaces",
"Microsoft.Web/hostingEnvironments",
"Microsoft.Web/serverFarms",
"NGINX.NGINXPLUS/nginxDeployments",
"Oracle.Database/networkAttachments",
"PaloAltoNetworks.Cloudngfw/firewalls",
"PureStorage.Block/storagePools",
"Qumulo.Storage/fileSystems"
],
dv.service_name)
]]))
error_message = "Delegation service_name must be one of the supported Azure service types."
}
# Azure CLI command to refresh the list of available actions for service delegations:
# locations=$(az account list-locations --query "[].name" --output tsv) && for location in $locations; do az network vnet subnet list-available-delegations --query "[].actions[]" --location $location --output tsv 2>/dev/null; done | sort | uniq | awk -F, -v OFS='","' -v q='"' '{$1=$1; print q $0 q}' | awk '{printf "%s%s",sep,$0; sep=",\n"} END{print ""}'
validation {
condition = alltrue(flatten([
for k, v in var.subnets : [
for dk, dv in v.delegation : [
for action in dv.actions : contains([
"Microsoft.Network/networkinterfaces/*",
"Microsoft.Network/publicIPAddresses/join/action",
"Microsoft.Network/publicIPAddresses/read",
"Microsoft.Network/virtualNetworks/read",
"Microsoft.Network/virtualNetworks/subnets/action",
"Microsoft.Network/virtualNetworks/subnets/join/action",
"Microsoft.Network/virtualNetworks/subnets/prepareNetworkPolicies/action",
"Microsoft.Network/virtualNetworks/subnets/unprepareNetworkPolicies/action"
], action)
]
]]
))
error_message = "Delegation actions must be from the supported Azure actions."
}
}
variable "tags" {
default = {}
description = "Virtual network tags."
type = map(string)
}