-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.bicep
270 lines (260 loc) · 8.46 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
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
@description('The name of the workspace to create.')
param workspaceName string = 'dbx-pv-01'
@description('vnet prefix address')
param vnetAddressPrefixParam string = '10.101'
var addressPrefix = '${vnetAddressPrefixParam}.0.0/16'
@description('Specify whether to provision new vnet or deploy to existing vnet')
@allowed([
'new'
'existing'
])
param vnetNewOrExisting string = 'existing'
param vnetName string = 'dwwaf-vnet'
var privateDnsZoneName = 'privatelink.azuredatabricks.net'
var privateEndpointNameBrowserAuth = '${workspaceName}-pvtEndpoint-browserAuth'
module nsg 'br/public:avm/res/network/network-security-group:0.1.2' = {
name: '${uniqueString(deployment().name, 'uksouth')}-dwwaf-nsg'
params: {
name: 'dwwaf-nsg'
location: 'uksouth'
securityRules: [
{
name: 'AllowBastionToVM'
properties: {
description: 'Allow Azure Bastion to connect to the VM on RDP port 3389.'
protocol: 'Tcp'
sourcePortRange: '*'
destinationPortRange: '3389'
sourceAddressPrefix: 'VirtualNetwork'
destinationAddressPrefix: '*'
access: 'Allow'
priority: 101
direction: 'Inbound'
}
}
{
name: 'AllowAzureBastionTraffic'
properties: {
description: 'Allow Azure Bastion service traffic to AzureBastionSubnet.'
protocol: 'Tcp'
sourcePortRange: '*'
destinationPortRange: '443'
sourceAddressPrefix: '10.101.129.0/26' //AzureBastionSubnet
destinationAddressPrefix: '*'
access: 'Allow'
priority: 100
direction: 'Inbound'
}
}
{
name: 'Microsoft.Databricks-workspaces_UseOnly_databricks-worker-to-worker-inbound'
properties: {
description: 'Required for worker nodes communication within a cluster.'
protocol: '*'
sourcePortRange: '*'
destinationPortRange: '*'
sourceAddressPrefix: 'VirtualNetwork'
destinationAddressPrefix: 'VirtualNetwork'
access: 'Allow'
priority: 102
direction: 'Inbound'
}
}
{
name: 'Microsoft.Databricks-workspaces_UseOnly_databricks-worker-to-databricks-webapp'
properties: {
description: 'Required for workers communication with Databricks Webapp.'
protocol: 'Tcp'
sourcePortRange: '*'
destinationPortRange: '443'
sourceAddressPrefix: 'VirtualNetwork'
destinationAddressPrefix: 'AzureDatabricks'
access: 'Allow'
priority: 103
direction: 'Outbound'
}
}
{
name: 'Microsoft.Databricks-workspaces_UseOnly_databricks-worker-to-sql'
properties: {
description: 'Required for workers communication with Azure SQL services.'
protocol: 'Tcp'
sourcePortRange: '*'
destinationPortRange: '3306'
sourceAddressPrefix: 'VirtualNetwork'
destinationAddressPrefix: 'Sql'
access: 'Allow'
priority: 104
direction: 'Outbound'
}
}
{
name: 'Microsoft.Databricks-workspaces_UseOnly_databricks-worker-to-storage'
properties: {
description: 'Required for workers communication with Azure Storage services.'
protocol: 'Tcp'
sourcePortRange: '*'
destinationPortRange: '443'
sourceAddressPrefix: 'VirtualNetwork'
destinationAddressPrefix: 'Storage'
access: 'Allow'
priority: 105
direction: 'Outbound'
}
}
{
name: 'Microsoft.Databricks-workspaces_UseOnly_databricks-worker-to-worker-outbound'
properties: {
description: 'Required for worker nodes communication within a cluster.'
protocol: '*'
sourcePortRange: '*'
destinationPortRange: '*'
sourceAddressPrefix: 'VirtualNetwork'
destinationAddressPrefix: 'VirtualNetwork'
access: 'Allow'
priority: 106
direction: 'Outbound'
}
}
{
name: 'Microsoft.Databricks-workspaces_UseOnly_databricks-worker-to-eventhub'
properties: {
description: 'Required for worker communication with Azure Eventhub services.'
protocol: 'Tcp'
sourcePortRange: '*'
destinationPortRange: '9093'
sourceAddressPrefix: 'VirtualNetwork'
destinationAddressPrefix: 'EventHub'
access: 'Allow'
priority: 107
direction: 'Outbound'
}
}
]
}
}
module vnetwork 'br/public:avm/res/network/virtual-network:0.1.1' = if(vnetNewOrExisting == 'new') {
name: '${uniqueString(deployment().name, 'uksouth')}-dwwaf-vnet'
params: {
name: vnetName
location: 'uksouth'
addressPrefixes: [addressPrefix]
subnets: [
{
name: 'private-subnet'
addressPrefix: cidrSubnet(addressPrefix, 20, 2) //privateSubnetCidr
networkSecurityGroupResourceId: nsg.outputs.resourceId
delegations: [
{
name: 'databricks-del-private'
properties: {
serviceName: 'Microsoft.Databricks/workspaces'
}
}
]
}
{
name: 'public-subnet'
addressPrefix: cidrSubnet(addressPrefix, 20, 1) //publicSubnetCidr
networkSecurityGroupResourceId: nsg.outputs.resourceId
delegations: [
{
name: 'databricks-del-public'
properties: {
serviceName: 'Microsoft.Databricks/workspaces'
}
}
]
}
{
name: 'defaultSubnet'
addressPrefix: cidrSubnet(addressPrefix, 20, 0)
}
{
name: 'AzureBastionSubnet'
addressPrefix: '10.101.129.0/26'
}
]
}
}
module workspace 'br/public:avm/res/databricks/workspace:0.8.5' = {
name: '${uniqueString(deployment().name, 'uksouth')}-databricksworkspace'
params: {
name: workspaceName
customPrivateSubnetName: vnetwork.outputs.subnetNames[0]
customPublicSubnetName: vnetwork.outputs.subnetNames[1]
customVirtualNetworkResourceId: vnetwork.outputs.resourceId
disablePublicIp: true
location: 'uksouth'
publicIpName: 'nat-gw-public-ip'
natGatewayName: 'nat-gateway' //nsg.outputs.name
prepareEncryption: true
publicNetworkAccess: 'Disabled'
requiredNsgRules: 'NoAzureDatabricksRules'
requireInfrastructureEncryption: true
skuName: 'premium'
storageAccountName: 'strge${uniqueString(resourceGroup().id)}'
storageAccountSkuName: 'Standard_ZRS'
vnetAddressPrefix: vnetAddressPrefixParam
privateEndpoints: [
{
privateDnsZoneGroup: {
privateDnsZoneGroupConfigs: [
{
privateDnsZoneResourceId: privateDnsZone.outputs.resourceId
}
]
}
service: 'databricks_ui_api'
subnetResourceId: vnetwork.outputs.subnetResourceIds[2]
tags: {
Environment: 'Non-Prod'
Role: 'DeploymentValidation'
}
}
]
}
}
module privateDnsZone 'br/public:avm/res/network/private-dns-zone:0.2.3' = {
name: '${uniqueString(deployment().name, 'uksouth')}-pvdnszone'
params: {
name: privateDnsZoneName
location: 'global'
virtualNetworkLinks: [
{
registrationEnabled: false
virtualNetworkResourceId: vnetwork.outputs.resourceId
}
]
}
}
module privateEndpoint_browserAuth 'br/public:avm/res/network/private-endpoint:0.3.3' = {
name: '${uniqueString(deployment().name, 'uksouth')}-browserauth-pe'
params: {
name: privateEndpointNameBrowserAuth
location: 'uksouth'
subnetResourceId: vnetwork.outputs.subnetResourceIds[2]
privateDnsZoneGroupName: 'config2'
privateDnsZoneResourceIds: [
privateDnsZone.outputs.resourceId
]
privateLinkServiceConnections: [
{
name: privateEndpointNameBrowserAuth
properties: {
groupIds: [
'browser_authentication'
]
privateLinkServiceId: workspace.outputs.resourceId
}
}
]
}
}
output vnetId string = vnetwork.outputs.resourceId
output vnetRG string = vnetwork.outputs.resourceGroupName
output vnetSub0 string = vnetwork.outputs.subnetResourceIds[0]
output vnetSub1 string = vnetwork.outputs.subnetResourceIds[1]
output vnetSub2 string = vnetwork.outputs.subnetResourceIds[2]
output nsgId string = nsg.outputs.resourceId
output ngsname string = nsg.outputs.name