-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathSpokeResourceGroup.bicep
105 lines (93 loc) · 2.78 KB
/
SpokeResourceGroup.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
targetScope = 'subscription'
param location string
param AddressSpace string
param counter int
param adminUsername string
@secure()
param adminPassword string
param deployVMsInSpokes bool
param deployFirewallInHub bool
param deployUDRs bool
param AzureFirewallpip string
param HubDeployed bool
param spokeRgNamePrefix string
param vmSize string
param tagsByResource object
param osType string
param firewallDNSproxy bool
param diagnosticWorkspaceId string
param dcrID string
var vnetName = 'VNET-Spoke${counter}'
var vmName = 'VM-Spoke${counter}'
var rtName = 'RT-Spoke${counter}'
var nsgName = 'NSG-Spoke${counter}'
var defaultSubnetPrefix = cidrSubnet(AddressSpace, 26, 0)
resource spokerg 'Microsoft.Resources/resourceGroups@2023-07-01' = {
name: '${spokeRgNamePrefix}${counter}'
location: location
tags: tagsByResource[?'Microsoft.Resources/subscriptions/resourceGroups'] ?? {}
}
module vnet 'modules/vnet.bicep' = {
scope: spokerg
name: vnetName
params: {
location: location
vnetAddressSpcae: AddressSpace
nsgID: nsg.outputs.nsgID
rtDefID: deployFirewallInHub && HubDeployed && deployUDRs ? rt.outputs.rtID : 'none'
vnetname: vnetName
deployDefaultSubnet: true
defaultSubnetPrefix: defaultSubnetPrefix
tagsByResource: tagsByResource
firewallDNSproxy: firewallDNSproxy
azFwIp: AzureFirewallpip
}
}
module vm 'modules/vm.bicep' = if (deployVMsInSpokes) {
scope: spokerg
name: vmName
params: {
adminPassword: adminPassword
adminUsername: adminUsername
location: location
subnetID: vnet.outputs.defaultSubnetID
vmName: vmName
vmSize: vmSize
tagsByResource: tagsByResource
osType: osType
diagnosticWorkspaceId: diagnosticWorkspaceId
dcrID: dcrID
}
}
module nsg 'modules/nsg.bicep' = {
scope: spokerg
name: nsgName
params: {
location: location
nsgName: nsgName
tagsByResource: tagsByResource
}
}
module rt 'modules/routetable.bicep' = if (deployFirewallInHub && HubDeployed && deployUDRs) {
scope: spokerg
name: rtName
params: {
location: location
rtName: rtName
tagsByResource: tagsByResource
}
}
module route1 'modules/route.bicep' = if (deployFirewallInHub && HubDeployed && deployUDRs) {
scope: spokerg
name: 'RouteToInternet'
params: {
routeAddressPrefix: '0.0.0.0/0'
routeName: deployFirewallInHub && HubDeployed && deployUDRs ? '${rt.outputs.rtName}/toInternet' : 'dummy1'
routeNextHopIpAddress: deployFirewallInHub && HubDeployed && deployUDRs ? AzureFirewallpip : '1.2.3.4'
}
}
output spokeVnetID string = vnet.outputs.vnetID
output spokeVnetAddressSpace string = AddressSpace
output spokeResourceGroupName string = spokerg.name
output spokeVnetName string = vnet.outputs.vnetName
output spokeVmResourceID string = deployVMsInSpokes ? vm.outputs.vmResourceID : 'none'