-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.bicep
194 lines (174 loc) · 4.44 KB
/
main.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
targetScope = 'subscription'
@description('Specify the location for the hub Virtual Network and its related resources')
param location string = 'westeurope'
@description('Specify the location for the vWAN and its related resources')
param vwanlocation string = 'eastus'
@description('Specify the name prefix for all resources and resource groups')
param nameprefix string = 'contoso'
@secure()
@description('Pre-Shared Key used to establish the site to site tunnel between the Virtual Hub and On-Prem VNet')
param psk string = uniqueString(subscription().id)
var vnetname = '${nameprefix}-vnet'
var vpngwname = '${vnetname}-vpn-gw'
var vpngwpipname = '${vnetname}-vpn-gw'
var vpnconname = '${vnetname}-to-${vhubname}-cn'
var lgwname = '${vwanlocation}-site-lgw'
var fwname = '${vnetname}-fw'
var fwpolicyname = '${nameprefix}-${location}-fw-policy'
var fwpipname = '${vnetname}-fw-pip'
var fwprefixname = '${vnetname}-fw-ipprefix'
var vwanname = '${nameprefix}-vwan'
var vhubname = '${nameprefix}-vhub-${vwanlocation}'
var vhubfwname = '${vhubname}-fw'
var vhubfwpolicyname = '${nameprefix}-${vwanlocation}-fw-policy'
var vhubvpngwname = '${vhubname}-vpn-gw'
resource hubrg 'Microsoft.Resources/resourceGroups@2020-06-01' = {
name: '${nameprefix}-hubvnet-rg'
location: vwanlocation
}
resource vwanrg 'Microsoft.Resources/resourceGroups@2020-06-01' = {
name: '${nameprefix}-vwan-rg'
location: location
}
module vnet './vnet.bicep' = {
name: vnetname
scope: hubrg
params: {
vnetname: vnetname
location: location
addressprefix: '10.0.0.0/20'
serversubnetprefix: '10.0.0.0/24'
bastionsubnetprefix: '10.0.1.0/24'
firewallsubnetprefix: '10.0.2.0/24'
gatewaysubnetprefix: '10.0.3.0/24'
}
}
module vpngw './vnetvpngw.bicep' = {
name: 'vpngw-deploy'
scope: hubrg
params: {
location: location
vpngwname: vpngwname
subnetref: vnet.outputs.subnets[2].id
vpngwpipname: vpngwpipname
asn: 65010
}
}
module fwpolicy './azfwpolicy.bicep' = {
name: 'fwpolicy-deploy'
scope: hubrg
params: {
policyname: fwpolicyname
location: location
}
}
module fwpip './azfwpip.bicep' = {
name: 'pip-deploy'
scope: hubrg
params: {
location: location
pipname: fwpipname
ipprefixlength: 31
ipprefixname: fwprefixname
}
}
module fw './azfw.bicep' = {
name: 'fw-deploy'
scope: hubrg
params: {
location: location
fwname: fwname
fwtype: 'VNet'
fwpolicyid: fwpolicy.outputs.id
publicipid: fwpip.outputs.id
subnetid: vnet.outputs.subnets[3].id
}
}
module vwan './vwan.bicep' = {
name: 'vwan-deploy'
scope: vwanrg
params: {
location: vwanlocation
wanname: vwanname
wantype: 'Standard'
}
}
module vhub './vhub.bicep' = {
name: 'vhub-deploy'
scope: vwanrg
params: {
location: vwanlocation
hubname: vhubname
hubaddressprefix: '10.10.0.0/24'
wanid: vwan.outputs.id
}
}
module vhubfwpolicy './azfwpolicy.bicep' = {
name: 'vhubfwpolicy-deploy'
scope: vwanrg
params: {
policyname: vhubfwpolicyname
location: vwanlocation
}
}
module vhubfw './azfw.bicep' = {
name: 'vhubfw-deploy'
scope: vwanrg
params: {
location: vwanlocation
fwname: vhubfwname
fwtype: 'vWAN'
hubid: vhub.outputs.id
hubpublicipcount: 1
fwpolicyid: vhubfwpolicy.outputs.id
}
}
module vhubvpngw './vhubvpngw.bicep' = {
name: 'vhubvpngw'
scope: vwanrg
params: {
location: vwanlocation
hubvpngwname: vhubvpngwname
hubid: vhub.outputs.id
asn: 65515
}
}
module vwanvpnsite './vwanvpnsite.bicep' = {
name: 'vwanvpnsite-deploy'
scope: vwanrg
params: {
vpnsitename: '${location}-vpnsite'
location: vwanlocation
addressprefix: vnet.outputs.vnetaddress[0]
bgppeeringpddress: vpngw.outputs.vpngwbgpaddress
ipaddress: vpngw.outputs.vpngwip
remotesiteasn: vpngw.outputs.bgpasn
wanid: vwan.outputs.id
}
}
module vhubs2s './vhubvpngwcon.bicep' = {
name: 'vhubs2s-deploy'
scope: vwanrg
params: {
hubvpngwname: vhubvpngw.outputs.name
psk: psk
vpnsiteid: vwanvpnsite.outputs.id
}
}
module vnets2s './vnetsitetosite.bicep' = {
name: 'vnets2s-deploy'
scope: hubrg
params: {
location: location
localnetworkgwname: lgwname
addressprefixes: [
vhub.outputs.vhubaddress
]
connectionname: vpnconname
bgppeeringpddress: vhubvpngw.outputs.gwprivateip
gwipaddress: vhubvpngw.outputs.gwpublicip
remotesiteasn: vhubvpngw.outputs.bgpasn
psk: psk
vpngwid: vpngw.outputs.id
}
}