-
Notifications
You must be signed in to change notification settings - Fork 1
/
vnet.bicep
166 lines (156 loc) · 4.04 KB
/
vnet.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
param location string = resourceGroup().location
param vnetname string
@description('Specifies the VNet Address Prefix.')
param addressprefix string = '10.0.1.0/24'
@description('Specifies the Subnet Address Prefix for the server subnet')
param serversubnetprefix string = '10.0.1.0/26'
@description('Specifies the Subnet Address Prefix for the bastion subnet')
param bastionsubnetprefix string = '10.0.1.64/26'
@description('Specifies the Subnet Address Prefix for the GatewaySubnet')
param gatewaysubnetprefix string = '10.0.1.128/26'
@description('Specifies the Subnet Address Prefix for the AzureFirewallSubnet')
param firewallsubnetprefix string = '10.0.1.192/26'
var servernsgname = '${vnetname}-snet-servers-nsg'
var bastionnsgname = '${vnetname}-AzureBastionSubnet-nsg'
var bastionnsgrules = {
securityRules: [
{
name: 'bastion-in-allow'
properties: {
protocol: 'Tcp'
sourcePortRange: '*'
sourceAddressPrefix: '*'
destinationPortRange: '443'
destinationAddressPrefix: '*'
access: 'Allow'
priority: 100
direction: 'Inbound'
}
}
{
name: 'bastion-control-in-allow'
properties: {
protocol: 'Tcp'
sourcePortRange: '*'
sourceAddressPrefix: 'GatewayManager'
destinationPortRanges: [
'443'
'4443'
]
destinationAddressPrefix: '*'
access: 'Allow'
priority: 120
direction: 'Inbound'
}
}
{
name: 'bastion-in-deny'
properties: {
protocol: '*'
sourcePortRange: '*'
destinationPortRange: '*'
sourceAddressPrefix: '*'
destinationAddressPrefix: '*'
access: 'Deny'
priority: 4096
direction: 'Inbound'
}
}
{
name: 'bastion-vnet-ssh-out-allow'
properties: {
protocol: 'Tcp'
sourcePortRange: '*'
sourceAddressPrefix: '*'
destinationPortRange: '22'
destinationAddressPrefix: 'VirtualNetwork'
access: 'Allow'
priority: 100
direction: 'Outbound'
}
}
{
name: 'bastion-vnet-rdp-out-allow'
properties: {
protocol: 'Tcp'
sourcePortRange: '*'
sourceAddressPrefix: '*'
destinationPortRange: '3389'
destinationAddressPrefix: 'VirtualNetwork'
access: 'Allow'
priority: 110
direction: 'Outbound'
}
}
{
name: 'bastion-azure-out-allow'
properties: {
protocol: 'Tcp'
sourcePortRange: '*'
sourceAddressPrefix: '*'
destinationPortRange: '443'
destinationAddressPrefix: 'AzureCloud'
access: 'Allow'
priority: 120
direction: 'Outbound'
}
}
]
}
resource servernsg 'Microsoft.Network/networkSecurityGroups@2020-05-01' = {
name: servernsgname
location: location
}
resource bastionnsg 'Microsoft.Network/networkSecurityGroups@2020-06-01' = {
name: bastionnsgname
location: location
properties: {
securityRules: bastionnsgrules.securityRules
}
}
resource vnet 'Microsoft.Network/virtualNetworks@2020-05-01' = {
name: vnetname
location: location
properties: {
addressSpace: {
addressPrefixes: [
addressprefix
]
}
subnets: [
{
name: 'snet-servers'
properties: {
addressPrefix: serversubnetprefix
networkSecurityGroup: {
id: servernsg.id
}
}
}
{
name: 'AzureBastionSubnet'
properties: {
addressPrefix: bastionsubnetprefix
networkSecurityGroup: {
id: bastionnsg.id
}
}
}
{
name: 'GatewaySubnet'
properties: {
addressPrefix: gatewaysubnetprefix
}
}
{
name: 'AzureFirewallSubnet'
properties: {
addressPrefix: firewallsubnetprefix
}
}
]
}
}
output id string = vnet.id
output subnets array = vnet.properties.subnets
output vnetaddress array = any(vnet.properties.addressSpace.addressPrefixes)