-
Notifications
You must be signed in to change notification settings - Fork 517
/
vwanConnectivity.bicep
613 lines (516 loc) · 24.8 KB
/
vwanConnectivity.bicep
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
metadata name = 'ALZ Bicep - Azure vWAN Connectivity Module'
metadata description = 'Module used to set up vWAN Connectivity'
type virtualWanOptionsType = ({
@sys.description('Switch to enable/disable VPN Gateway deployment on the respective Virtual WAN Hub.')
parVpnGatewayEnabled: bool
@sys.description('Switch to enable/disable ExpressRoute Gateway deployment on the respective Virtual WAN Hub.')
parExpressRouteGatewayEnabled: bool
@sys.description('Switch to enable/disable Azure Firewall deployment on the respective Virtual WAN Hub.')
parAzFirewallEnabled: bool
@sys.description('The IP address range in CIDR notation for the vWAN virtual Hub to use.')
parVirtualHubAddressPrefix: string
@sys.description('The Virtual WAN Hub location.')
parHubLocation: string
@sys.description('The Virtual WAN Hub routing preference. The allowed values are `ASN`, `VpnGateway`, `ExpressRoute`.')
parHubRoutingPreference: ('ExpressRoute' | 'VpnGateway' | 'ASN')
@sys.description('The Virtual WAN Hub capacity. The value should be between 2 to 50.')
@minValue(2)
@maxValue(50)
parVirtualRouterAutoScaleConfiguration: int
@sys.description('The Virtual WAN Hub routing intent destinations, leave empty if not wanting to enable routing intent. The allowed values are `Internet`, `PrivateTraffic`.')
parVirtualHubRoutingIntentDestinations: ('Internet' | 'PrivateTraffic')[]
@sys.description('This parameter is used to specify a custom name for the VPN Gateway.')
parVpnGatewayCustomName: string?
@sys.description('This parameter is used to specify a custom name for the ExpressRoute Gateway.')
parExpressRouteGatewayCustomName: string?
@sys.description('This parameter is used to specify a custom name for the Azure Firewall.')
parAzFirewallCustomName: string?
@sys.description('This parameter is used to specify a custom name for the Virtual WAN Hub.')
parVirtualWanHubCustomName: string?
})[]
type lockType = {
@description('Optional. Specify the name of lock.')
name: string?
@description('Optional. The lock settings of the service.')
kind: ('CanNotDelete' | 'ReadOnly' | 'None')
@description('Optional. Notes about this lock.')
notes: string?
}
@sys.description('Region in which the resource group was created.')
param parLocation string = resourceGroup().location
@sys.description('Prefix value which will be prepended to all resource names.')
param parCompanyPrefix string = 'alz'
@sys.description('''Global Resource Lock Configuration used for all resources deployed in this module.
- `kind` - The lock settings of the service which can be CanNotDelete, ReadOnly, or None.
- `notes` - Notes about this lock.
''')
param parGlobalResourceLock lockType = {
kind: 'None'
notes: 'This lock was created by the ALZ Bicep vWAN Connectivity Module.'
}
@sys.description('Azure Firewall Tier associated with the Firewall to deploy.')
@allowed([
'Basic'
'Standard'
'Premium'
])
param parAzFirewallTier string = 'Standard'
@sys.description('The Azure Firewall Threat Intelligence Mode.')
@allowed([
'Alert'
'Deny'
'Off'
])
param parAzFirewallIntelMode string = 'Alert'
@sys.description('Switch to enable/disable Virtual Hub deployment.')
param parVirtualHubEnabled bool = true
@sys.description('Switch to enable/disable Azure Firewall DNS Proxy.')
param parAzFirewallDnsProxyEnabled bool = true
@sys.description('Array of custom DNS servers used by Azure Firewall.')
param parAzFirewallDnsServers array = []
@sys.description('Prefix Used for Virtual WAN.')
param parVirtualWanName string = '${parCompanyPrefix}-vwan-${parLocation}'
@sys.description('''Resource Lock Configuration for Virtual WAN.
- `kind` - The lock settings of the service which can be CanNotDelete, ReadOnly, or None.
- `notes` - Notes about this lock.
''')
param parVirtualWanLock lockType = {
kind: 'None'
notes: 'This lock was created by the ALZ Bicep vWAN Connectivity Module.'
}
@sys.description('Prefix Used for Virtual WAN Hub.')
param parVirtualWanHubName string = '${parCompanyPrefix}-vhub'
@sys.description('The name of the route table that manages routing between the Virtual WAN Hub and the Azure Firewall.')
param parVirtualWanHubDefaultRouteName string = 'default-to-azfw'
@sys.description('''Array Used for multiple Virtual WAN Hubs deployment. Each object in the array represents an individual Virtual WAN Hub configuration. Add/remove additional objects in the array to meet the number of Virtual WAN Hubs required.
- `parVpnGatewayEnabled` - Switch to enable/disable VPN Gateway deployment on the respective Virtual WAN Hub.
- `parExpressRouteGatewayEnabled` - Switch to enable/disable ExpressRoute Gateway deployment on the respective Virtual WAN Hub.
- `parAzFirewallEnabled` - Switch to enable/disable Azure Firewall deployment on the respective Virtual WAN Hub.
- `parVirtualHubAddressPrefix` - The IP address range in CIDR notation for the vWAN virtual Hub to use.
- `parHubLocation` - The Virtual WAN Hub location.
- `parHubRoutingPreference` - The Virtual WAN Hub routing preference. The allowed values are `ASN`, `VpnGateway`, `ExpressRoute`.
- `parVirtualRouterAutoScaleConfiguration` - The Virtual WAN Hub capacity. The value should be between 2 to 50.
- `parVirtualHubRoutingIntentDestinations` - The Virtual WAN Hub routing intent destinations, leave empty if not wanting to enable routing intent. The allowed values are `Internet`, `PrivateTraffic`.
''')
param parVirtualWanHubs virtualWanOptionsType = [ {
parVpnGatewayEnabled: true
parExpressRouteGatewayEnabled: true
parAzFirewallEnabled: true
parVirtualHubAddressPrefix: '10.100.0.0/23'
parHubLocation: parLocation
parHubRoutingPreference: 'ExpressRoute'
parVirtualRouterAutoScaleConfiguration: 2
parVirtualHubRoutingIntentDestinations: []
}
]
@sys.description('''Resource Lock Configuration for Virtual WAN Hub VPN Gateway.
- `kind` - The lock settings of the service which can be CanNotDelete, ReadOnly, or None.
- `notes` - Notes about this lock.
''')
param parVpnGatewayLock lockType = {
kind: 'None'
notes: 'This lock was created by the ALZ Bicep vWAN Connectivity Module.'
}
@sys.description('''Resource Lock Configuration for Virtual WAN Hub ExpressRoute Gateway.
- `kind` - The lock settings of the service which can be CanNotDelete, ReadOnly, or None.
- `notes` - Notes about this lock.
''')
param parExpressRouteGatewayLock lockType = {
kind: 'None'
notes: 'This lock was created by the ALZ Bicep vWAN Connectivity Module.'
}
@sys.description('''Resource Lock Configuration for Virtual WAN Hub.
- `kind` - The lock settings of the service which can be CanNotDelete, ReadOnly, or None.
- `notes` - Notes about this lock.
''')
param parVirtualWanHubsLock lockType = {
kind: 'None'
notes: 'This lock was created by the ALZ Bicep vWAN Connectivity Module.'
}
@sys.description('VPN Gateway Name.')
param parVpnGatewayName string = '${parCompanyPrefix}-vpngw'
@sys.description('ExpressRoute Gateway Name.')
param parExpressRouteGatewayName string = '${parCompanyPrefix}-ergw'
@sys.description('Azure Firewall Name.')
param parAzFirewallName string = '${parCompanyPrefix}-fw'
@allowed([
'1'
'2'
'3'
])
@sys.description('Availability Zones to deploy the Azure Firewall across. Region must support Availability Zones to use. If it does not then leave empty.')
param parAzFirewallAvailabilityZones array = []
@sys.description('Azure Firewall Policies Name.')
param parAzFirewallPoliciesName string = '${parCompanyPrefix}-azfwpolicy-${parLocation}'
@sys.description('''Resource Lock Configuration for Azure Firewall.
- `kind` - The lock settings of the service which can be CanNotDelete, ReadOnly, or None.
- `notes` - Notes about this lock.
''')
param parAzureFirewallLock lockType = {
kind: 'None'
notes: 'This lock was created by the ALZ Bicep vWAN Connectivity Module.'
}
@sys.description('The scale unit for this VPN Gateway.')
param parVpnGatewayScaleUnit int = 1
@sys.description('The scale unit for this ExpressRoute Gateway.')
param parExpressRouteGatewayScaleUnit int = 1
@sys.description('Switch to enable/disable DDoS Network Protection deployment.')
param parDdosEnabled bool = true
@sys.description('DDoS Plan Name.')
param parDdosPlanName string = '${parCompanyPrefix}-ddos-plan'
@sys.description('''Resource Lock Configuration for DDoS Plan.
- `kind` - The lock settings of the service which can be CanNotDelete, ReadOnly, or None.
- `notes` - Notes about this lock.
''')
param parDdosLock lockType = {
kind: 'None'
notes: 'This lock was created by the ALZ Bicep vWAN Connectivity Module.'
}
@sys.description('Switch to enable/disable Private DNS Zones deployment.')
param parPrivateDnsZonesEnabled bool = true
@sys.description('Resource Group Name for Private DNS Zones.')
param parPrivateDnsZonesResourceGroup string = resourceGroup().name
@sys.description('Array of DNS Zones to provision in Hub Virtual Network.')
param parPrivateDnsZones array = [
'privatelink.${toLower(parLocation)}.azmk8s.io'
'privatelink.${toLower(parLocation)}.batch.azure.com'
'privatelink.${toLower(parLocation)}.kusto.windows.net'
'privatelink.adf.azure.com'
'privatelink.afs.azure.net'
'privatelink.agentsvc.azure-automation.net'
'privatelink.analysis.windows.net'
'privatelink.api.azureml.ms'
'privatelink.azconfig.io'
'privatelink.azure-api.net'
'privatelink.azure-automation.net'
'privatelink.azurecr.io'
'privatelink.azure-devices.net'
'privatelink.azure-devices-provisioning.net'
'privatelink.azuredatabricks.net'
'privatelink.azurehdinsight.net'
'privatelink.azurehealthcareapis.com'
'privatelink.azurestaticapps.net'
'privatelink.azuresynapse.net'
'privatelink.azurewebsites.net'
'privatelink.batch.azure.com'
'privatelink.blob.core.windows.net'
'privatelink.cassandra.cosmos.azure.com'
'privatelink.cognitiveservices.azure.com'
'privatelink.database.windows.net'
'privatelink.datafactory.azure.net'
'privatelink.dev.azuresynapse.net'
'privatelink.dfs.core.windows.net'
'privatelink.dicom.azurehealthcareapis.com'
'privatelink.digitaltwins.azure.net'
'privatelink.directline.botframework.com'
'privatelink.documents.azure.com'
'privatelink.eventgrid.azure.net'
'privatelink.file.core.windows.net'
'privatelink.gremlin.cosmos.azure.com'
'privatelink.guestconfiguration.azure.com'
'privatelink.his.arc.azure.com'
'privatelink.kubernetesconfiguration.azure.com'
'privatelink.managedhsm.azure.net'
'privatelink.mariadb.database.azure.com'
'privatelink.media.azure.net'
'privatelink.mongo.cosmos.azure.com'
'privatelink.monitor.azure.com'
'privatelink.mysql.database.azure.com'
'privatelink.notebooks.azure.net'
'privatelink.ods.opinsights.azure.com'
'privatelink.oms.opinsights.azure.com'
'privatelink.pbidedicated.windows.net'
'privatelink.postgres.database.azure.com'
'privatelink.prod.migration.windowsazure.com'
'privatelink.purview.azure.com'
'privatelink.purviewstudio.azure.com'
'privatelink.queue.core.windows.net'
'privatelink.redis.cache.windows.net'
'privatelink.redisenterprise.cache.azure.net'
'privatelink.search.windows.net'
'privatelink.service.signalr.net'
'privatelink.servicebus.windows.net'
'privatelink.siterecovery.windowsazure.com'
'privatelink.sql.azuresynapse.net'
'privatelink.table.core.windows.net'
'privatelink.table.cosmos.azure.com'
'privatelink.tip1.powerquery.microsoft.com'
'privatelink.token.botframework.com'
'privatelink.vaultcore.azure.net'
'privatelink.web.core.windows.net'
'privatelink.webpubsub.azure.com'
]
@sys.description('Set Parameter to false to skip the addition of a Private DNS Zone for Azure Backup.')
param parPrivateDnsZoneAutoMergeAzureBackupZone bool = true
@sys.description('Resource ID of VNet for Private DNS Zone VNet Links')
param parVirtualNetworkIdToLink string = ''
@sys.description('Resource ID of Failover VNet for Private DNS Zone VNet Failover Links')
param parVirtualNetworkIdToLinkFailover string = ''
@sys.description('''Resource Lock Configuration for Private DNS Zone(s).
- `kind` - The lock settings of the service which can be CanNotDelete, ReadOnly, or None.
- `notes` - Notes about this lock.
''')
param parPrivateDNSZonesLock lockType = {
kind: 'None'
notes: 'This lock was created by the ALZ Bicep vWAN Connectivity Module.'
}
@sys.description('Tags you would like to be applied to all resources in this module.')
param parTags object = {}
@sys.description('Set Parameter to true to Opt-out of deployment telemetry')
param parTelemetryOptOut bool = false
// Customer Usage Attribution Id Telemetry
var varCuaid = '7f94f23b-7a59-4a5c-9a8d-2a253a566f61'
// ZTN Telemetry
var varZtnP1CuaId = '3ab23b1e-c5c5-42d4-b163-1402384ba2db'
var varZtnP1Trigger = (parDdosEnabled && !(contains(map(parVirtualWanHubs, hub => hub.parAzFirewallEnabled), false)) && (parAzFirewallTier == 'Premium')) ? true : false
// Azure Firewalls in Hubs
var varAzureFirewallInHubs = filter(parVirtualWanHubs, hub => hub.parAzFirewallEnabled == true)
// Virtual WAN resource
resource resVwan 'Microsoft.Network/virtualWans@2023-04-01' = {
name: parVirtualWanName
location: parLocation
tags: parTags
properties: {
allowBranchToBranchTraffic: true
allowVnetToVnetTraffic: true
disableVpnEncryption: false
type: 'Standard'
}
}
// Create a Virtual WAN resource lock if parGlobalResourceLock.kind is not set to None and if parVirtualWanLock.kind is not set to None
resource resVwanLock 'Microsoft.Authorization/locks@2020-05-01' = if (parGlobalResourceLock.kind != 'None' && parVirtualWanLock.kind != 'None') {
scope: resVwan
name: parVirtualWanLock.?name ?? '${resVwan.name}-lock'
properties: {
level: (parGlobalResourceLock.kind != 'None') ? parGlobalResourceLock.kind : parVirtualWanLock.kind
notes: (parGlobalResourceLock.kind != 'None') ? parGlobalResourceLock.?notes : parVirtualWanLock.?notes
}
}
resource resVhub 'Microsoft.Network/virtualHubs@2023-04-01' = [for hub in parVirtualWanHubs: if (parVirtualHubEnabled && !empty(hub.parVirtualHubAddressPrefix)) {
name: hub.?parVirtualWanHubCustomName ?? '${parVirtualWanHubName}-${hub.parHubLocation}'
location: hub.parHubLocation
tags: parTags
properties: {
addressPrefix: hub.parVirtualHubAddressPrefix
sku: 'Standard'
virtualWan: {
id: resVwan.id
}
virtualRouterAutoScaleConfiguration: {
minCapacity: hub.parVirtualRouterAutoScaleConfiguration
}
hubRoutingPreference: hub.parHubRoutingPreference
}
}]
// Create a Virtual WAN Hub resource lock for each Virtual WAN Hub in parVirtualWanHubs if parGlobalResourceLock.kind is not set to None and if parVirtualWanHubsLock.kind is not set to None
resource resVhubLock 'Microsoft.Authorization/locks@2020-05-01' = [for (hub, i) in parVirtualWanHubs: if (parGlobalResourceLock.kind != 'None' && parVirtualWanHubsLock.kind != 'None') {
scope: resVhub[i]
name: parVirtualWanHubsLock.?name ?? '${resVhub[i].name}-lock'
properties: {
level: (parGlobalResourceLock.kind != 'None') ? parGlobalResourceLock.kind : parVirtualWanHubsLock.kind
notes: (parGlobalResourceLock.kind != 'None') ? parGlobalResourceLock.?notes : parVirtualWanHubsLock.?notes
}
}]
resource resVhubRouteTable 'Microsoft.Network/virtualHubs/hubRouteTables@2023-04-01' = [for (hub, i) in parVirtualWanHubs: if (parVirtualHubEnabled && hub.parAzFirewallEnabled && empty(hub.parVirtualHubRoutingIntentDestinations)) {
parent: resVhub[i]
name: 'defaultRouteTable'
properties: {
labels: [
'default'
]
routes: [
{
name: parVirtualWanHubDefaultRouteName
destinations: [
'0.0.0.0/0'
]
destinationType: 'CIDR'
nextHop: (parVirtualHubEnabled && hub.parAzFirewallEnabled) ? resAzureFirewall[i].id : ''
nextHopType: 'ResourceID'
}
]
}
}]
resource resVhubRoutingIntent 'Microsoft.Network/virtualHubs/routingIntent@2023-04-01' = [for (hub, i) in parVirtualWanHubs: if (parVirtualHubEnabled && hub.parAzFirewallEnabled && !empty(hub.parVirtualHubRoutingIntentDestinations)) {
parent: resVhub[i]
name: !empty(hub.?parVirtualWanHubCustomName) ? '${hub.parVirtualWanHubCustomName}-Routing-Intent' : '${parVirtualWanHubName}-${hub.parHubLocation}-Routing-Intent'
properties: {
routingPolicies: [for destination in hub.parVirtualHubRoutingIntentDestinations: {
name: destination == 'Internet' ? 'PublicTraffic' : destination == 'PrivateTraffic' ? 'PrivateTraffic' : 'N/A'
destinations: [
destination
]
nextHop: resAzureFirewall[i].id
}]
}
}]
resource resVpnGateway 'Microsoft.Network/vpnGateways@2023-02-01' = [for (hub, i) in parVirtualWanHubs: if ((parVirtualHubEnabled) && (hub.parVpnGatewayEnabled)) {
dependsOn: resVhub
name: hub.?parVpnGatewayCustomName ?? '${parVpnGatewayName}-${hub.parHubLocation}'
location: hub.parHubLocation
tags: parTags
properties: {
bgpSettings: {
asn: 65515
bgpPeeringAddress: ''
peerWeight: 5
}
virtualHub: {
id: resVhub[i].id
}
vpnGatewayScaleUnit: parVpnGatewayScaleUnit
}
}]
// Create a Virtual Network Gateway resource lock if gateway.name is not equal to noconfigVpn or noconfigEr and parGlobalResourceLock.kind != 'None' or if parVpnGatewayLock.kind != 'None'
resource resVpnGatewayLock 'Microsoft.Authorization/locks@2020-05-01' = [for (hub, i) in parVirtualWanHubs: if ((parVirtualHubEnabled) && (hub.parVpnGatewayEnabled) && (parVpnGatewayLock.kind != 'None' || parGlobalResourceLock.kind != 'None')) {
scope: resVpnGateway[i]
name: parVpnGatewayLock.?name ?? '${resVpnGateway[i].name}-lock'
properties: {
level: (parGlobalResourceLock.kind != 'None') ? parGlobalResourceLock.kind : parVpnGatewayLock.kind
notes: (parGlobalResourceLock.kind != 'None') ? parGlobalResourceLock.?notes : parVpnGatewayLock.?notes
}
}]
resource resErGateway 'Microsoft.Network/expressRouteGateways@2023-02-01' = [for (hub, i) in parVirtualWanHubs: if ((parVirtualHubEnabled) && (hub.parExpressRouteGatewayEnabled)) {
dependsOn: resVhub
name: hub.?parExpressRouteGatewayCustomName ?? '${parExpressRouteGatewayName}-${hub.parHubLocation}'
location: hub.parHubLocation
tags: parTags
properties: {
virtualHub: {
id: resVhub[i].id
}
autoScaleConfiguration: {
bounds: {
min: parExpressRouteGatewayScaleUnit
}
}
}
}]
// Create a Virtual Network Gateway resource lock if gateway.name is not equal to noconfigVpn or noconfigEr and parGlobalResourceLock.kind != 'None' or if parVpnGatewayLock.kind != 'None'
resource resErGatewayLock 'Microsoft.Authorization/locks@2020-05-01' = [for (hub, i) in parVirtualWanHubs: if ((parVirtualHubEnabled) && (hub.parExpressRouteGatewayEnabled) && (parExpressRouteGatewayLock.kind != 'None' || parGlobalResourceLock.kind != 'None')) {
scope: resErGateway[i]
name: parExpressRouteGatewayLock.?name ?? '${resErGateway[i].name}-lock'
properties: {
level: (parGlobalResourceLock.kind != 'None') ? parGlobalResourceLock.kind : parExpressRouteGatewayLock.kind
notes: (parGlobalResourceLock.kind != 'None') ? parGlobalResourceLock.?notes : parExpressRouteGatewayLock.?notes
}
}]
resource resFirewallPolicies 'Microsoft.Network/firewallPolicies@2023-02-01' = if (parVirtualHubEnabled && parVirtualWanHubs[0].parAzFirewallEnabled) {
name: parAzFirewallPoliciesName
location: parLocation
tags: parTags
properties: (parAzFirewallTier == 'Basic') ? {
sku: {
tier: parAzFirewallTier
}
threatIntelMode: 'Alert'
} : {
dnsSettings: {
enableProxy: parAzFirewallDnsProxyEnabled
servers: parAzFirewallDnsServers
}
sku: {
tier: parAzFirewallTier
}
threatIntelMode: parAzFirewallIntelMode
}
}
// Create Azure Firewall Policy resource lock if parAzFirewallEnabled is true and parGlobalResourceLock.kind != 'None' or if parAzureFirewallLock.kind != 'None'
resource resFirewallPoliciesLock 'Microsoft.Authorization/locks@2020-05-01' = if ((parVirtualHubEnabled && parVirtualWanHubs[0].parAzFirewallEnabled) && (parAzureFirewallLock.kind != 'None' || parGlobalResourceLock.kind != 'None')) {
scope: resFirewallPolicies
name: parAzureFirewallLock.?name ?? '${resFirewallPolicies.name}-lock'
properties: {
level: (parGlobalResourceLock.kind != 'None') ? parGlobalResourceLock.kind : parAzureFirewallLock.kind
notes: (parGlobalResourceLock.kind != 'None') ? parGlobalResourceLock.?notes : parAzureFirewallLock.?notes
}
}
resource resAzureFirewall 'Microsoft.Network/azureFirewalls@2023-02-01' = [for (hub, i) in parVirtualWanHubs: if ((parVirtualHubEnabled) && (hub.parAzFirewallEnabled)) {
name: hub.?parAzFirewallCustomName ?? '${parAzFirewallName}-${hub.parHubLocation}'
location: hub.parHubLocation
tags: parTags
zones: (!empty(parAzFirewallAvailabilityZones) ? parAzFirewallAvailabilityZones : null)
properties: {
hubIPAddresses: {
publicIPs: {
count: 1
}
}
sku: {
name: 'AZFW_Hub'
tier: parAzFirewallTier
}
virtualHub: {
id: parVirtualHubEnabled ? resVhub[i].id : ''
}
firewallPolicy: {
id: (parVirtualHubEnabled && hub.parAzFirewallEnabled) ? resFirewallPolicies.id : ''
}
}
}]
// Create Azure Firewall resource lock if parAzFirewallEnabled is true and parGlobalResourceLock.kind != 'None' or if parAzureFirewallLock.kind != 'None'
resource resAzureFirewallLock 'Microsoft.Authorization/locks@2020-05-01' = [for (hub, i) in parVirtualWanHubs: if ((parVirtualHubEnabled) && (hub.parAzFirewallEnabled) && (parAzureFirewallLock.kind != 'None' || parGlobalResourceLock.kind != 'None')) {
scope: resAzureFirewall[i]
name: parAzureFirewallLock.?name ?? '${resAzureFirewall[i].name}-lock'
properties: {
level: (parGlobalResourceLock.kind != 'None') ? parGlobalResourceLock.kind : parAzureFirewallLock.kind
notes: (parGlobalResourceLock.kind != 'None') ? parGlobalResourceLock.?notes : parAzureFirewallLock.?notes
}
}]
// DDoS plan is deployed even though not supported to attach to Virtual WAN today as per https://docs.microsoft.com/azure/firewall-manager/overview#known-issues - However, it can still be linked via policy to spoke VNets etc.
resource resDdosProtectionPlan 'Microsoft.Network/ddosProtectionPlans@2023-02-01' = if (parDdosEnabled) {
name: parDdosPlanName
location: parLocation
tags: parTags
}
// Create resource lock if parDdosEnabled is true and parGlobalResourceLock.kind != 'None' or if parDdosLock.kind != 'None'
resource resDDoSProtectionPlanLock 'Microsoft.Authorization/locks@2020-05-01' = if (parDdosEnabled && (parDdosLock.kind != 'None' || parGlobalResourceLock.kind != 'None')) {
scope: resDdosProtectionPlan
name: parDdosLock.?name ?? '${resDdosProtectionPlan.name}-lock'
properties: {
level: (parGlobalResourceLock.kind != 'None') ? parGlobalResourceLock.kind : parDdosLock.kind
notes: (parGlobalResourceLock.kind != 'None') ? parGlobalResourceLock.?notes : parDdosLock.?notes
}
}
// Private DNS Zones cannot be linked to the Virtual WAN Hub today however, they can be linked to spokes as they are normal VNets as per https://docs.microsoft.com/azure/virtual-wan/howto-private-link
module modPrivateDnsZones '../privateDnsZones/privateDnsZones.bicep' = if (parPrivateDnsZonesEnabled) {
name: 'deploy-Private-DNS-Zones'
scope: resourceGroup(parPrivateDnsZonesResourceGroup)
params: {
parLocation: parLocation
parTags: parTags
parPrivateDnsZones: parPrivateDnsZones
parPrivateDnsZoneAutoMergeAzureBackupZone: parPrivateDnsZoneAutoMergeAzureBackupZone
parVirtualNetworkIdToLink: parVirtualNetworkIdToLink
parVirtualNetworkIdToLinkFailover: parVirtualNetworkIdToLinkFailover
parResourceLockConfig: (parGlobalResourceLock.kind != 'None') ? parGlobalResourceLock : parPrivateDNSZonesLock
}
}
// Optional Deployments for Customer Usage Attribution
module modCustomerUsageAttribution '../../CRML/customerUsageAttribution/cuaIdResourceGroup.bicep' = if (!parTelemetryOptOut) {
name: 'pid-${varCuaid}-${uniqueString(parLocation)}'
params: {}
}
module modCustomerUsageAttributionZtnP1 '../../CRML/customerUsageAttribution/cuaIdResourceGroup.bicep' = if (!parTelemetryOptOut && varZtnP1Trigger) {
name: 'pid-${varZtnP1CuaId}-${uniqueString(parLocation)}'
params: {}
}
// Output Virtual WAN name and ID
output outVirtualWanName string = resVwan.name
output outVirtualWanId string = resVwan.id
// Output Virtual WAN Hub name and ID
output outVirtualHubName array = [for (hub, i) in parVirtualWanHubs: {
virtualhubname: resVhub[i].name
virtualhubid: resVhub[i].id
}]
output outVirtualHubId array = [for (hub, i) in parVirtualWanHubs: {
virtualhubid: resVhub[i].id
}]
// Output DDoS Plan ID
output outDdosPlanResourceId string = resDdosProtectionPlan.id
// Output Private DNS Zones
output outPrivateDnsZones array = (parPrivateDnsZonesEnabled ? modPrivateDnsZones.outputs.outPrivateDnsZones : [])
output outPrivateDnsZonesNames array = (parPrivateDnsZonesEnabled ? modPrivateDnsZones.outputs.outPrivateDnsZonesNames : [])
// Output Azure Firewall Private IP's
output outAzFwPrivateIps array = [for (hub, i) in varAzureFirewallInHubs: {
'${parVirtualWanHubName}-${hub.parHubLocation}': resAzureFirewall[i].properties.hubIPAddresses.privateIPAddress
}]