forked from lordlinus/databricks-all-in-one-bicep-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.bicep
321 lines (295 loc) · 10.4 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
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
targetScope = 'subscription'
@minLength(2)
@maxLength(4)
@description('2-4 chars to prefix the Azure resources, NOTE: no number or symbols')
param prefix string = 'ab'
@description('Client PC username, NOTE: do not use admin')
param adminUsername string
@description('Client PC password, with atleast 8 char length containing uppercase, digits and special characters ')
@minLength(8)
@secure()
param adminPassword string
@description('The number of nodes for the cluster.')
@minValue(3)
@maxValue(50)
param aksAgentCount int = 3
@description('The size of the VM instances')
param aksAgentVMSize string = 'Standard_A4_v2'
var uniqueSubString = '${uniqueString(guid(subscription().subscriptionId))}'
var uString = '${prefix}${uniqueSubString}'
// @description('Default storage suffix core - core.windows.net')
// var storageSuffix = environment().suffixes.storage
var storageAccountName = '${substring(uString, 0, 10)}stg01'
var keyVaultName = '${substring(uString, 0, 6)}akv00'
var resourceGroupName = '${substring(uString, 0, 6)}-rg'
var adbWorkspaceName = '${substring(uString, 0, 6)}AdbWksp'
var nsgName = '${substring(uString, 0, 6)}nsg'
var firewallName = '${substring(uString, 0, 6)}HubFW'
var firewallPublicIpName = '${substring(uString, 0, 6)}FWPIp'
var fwRoutingTable = '${substring(uString, 0, 6)}AdbRoutingTbl'
var clientPcName = '${substring(uString, 0, 6)}ClientPc'
var eHNameSpace = '${substring(uString, 0, 6)}eh'
var adbAkvLinkName = '${substring(uString, 0, 6)}SecretScope'
var amlWorkspaceName = '${substring(uString, 0, 6)}AmlWksp'
var containerRegistryName = '${substring(uString, 0, 6)}registry'
var applicationInsightsName = '${substring(uString, 0, 6)}AppInsights'
var sslLeafName = '${toLower(substring(uString, 0, 6))}'
var aksAmlComputeName = 'aks-for-aml'
// var routeTableName = 'RouteTable'
// creating the event hub same as namespace
var eventHubName = eHNameSpace
var managedIdentityName = '${substring(uString, 0, 6)}Identity'
@description('Default location of the resources')
param location string = 'southeastasia'
@description('')
param hubVnetName string = 'hubvnet'
@description('')
param spokeVnetName string = 'spokevnet'
@description('')
param HubVnetCidr string = '10.0.0.0/16'
@description('')
param FirewallSubnetCidr string = '10.0.1.0/26'
@description('')
param clientDevicesSubnetCidr string = '10.0.200.0/24'
// Divide 10.179.0.0/16 into 4 group for simplicity, each with 16382 address
// 10.179.0.0/18
// 10.179.64.0/18
// 10.179.128.0/18
// 10.179.192.0/18
@description('')
param SpokeVnetCidr string = '10.179.0.0/16'
@description('')
param PrivateSubnetCidr string = '10.179.0.0/18'
@description('')
param PublicSubnetCidr string = '10.179.64.0/18'
@description('')
param AksSubnetCidr string = '10.179.128.0/18'
@description('')
param PrivateLinkSubnetCidr string = '10.179.192.0/18'
@description('Southeastasia ADB webapp address')
param webappDestinationAddresses array = [
'52.187.145.107/32'
'52.187.0.85/32'
]
@description('Southeastasia ADB log blob')
param logBlobstorageDomains array = [
'dblogprodseasia.blob.${environment().suffixes.storage}'
]
@description('Southeastasia ADB extended ip')
param extendedInfraIp array = [
'20.195.104.64/28'
]
@description('Southeastasia SCC relay Domain')
param sccReplayDomain array = [
'tunnel.southeastasia.azuredatabricks.net'
]
@description('Southeastasia SDB metastore')
param metastoreDomains array = [
'consolidated-southeastasia-prod-metastore.mysql.database.azure.com'
]
@description('Southeastasia EventHub endpoint')
param eventHubEndpointDomain array = [
'prod-southeastasia-observabilityeventhubs.servicebus.windows.net'
]
@description('Southeastasia Artifacts Blob')
param artifactBlobStoragePrimaryDomains array = [
'dbartifactsprodseap.blob.${environment().suffixes.storage}'
'arprodseapa1.blob.${environment().suffixes.storage}'
'arprodseapa2.blob.${environment().suffixes.storage}'
'arprodseapa3.blob.${environment().suffixes.storage}'
'dbartifactsprodeap.blob.${environment().suffixes.storage}'
]
resource rg 'Microsoft.Resources/resourceGroups@2021-04-01' = {
name: resourceGroupName
location: location
}
module myIdentity './other/managedIdentity.template.bicep' = {
scope: rg
name: 'ManagedIdentity'
params: {
managedIdentityName: managedIdentityName
location: location
}
}
module nsg './network/securitygroup.template.bicep' = {
scope: rg
name: 'NetworkSecurityGroup'
params: {
securityGroupName: nsgName
}
}
module routeTable './network/routetable.template.bicep' = {
scope: rg
name: 'RouteTable'
params: {
routeTableName: fwRoutingTable
}
}
module vnets './network/vnet.template.bicep' = {
scope: rg
name: 'HubandSpokeVnets'
params: {
hubVnetName: hubVnetName
spokeVnetName: spokeVnetName
routeTableName: routeTable.outputs.routeTblName
securityGroupName: nsg.outputs.nsgName
firewallSubnetCidr: FirewallSubnetCidr
hubVnetCidr: HubVnetCidr
spokeVnetCidr: SpokeVnetCidr
publicSubnetCidr: PublicSubnetCidr
privateSubnetCidr: PrivateSubnetCidr
privatelinkSubnetCidr: PrivateLinkSubnetCidr
clinetDevicesSubnetCidr: clientDevicesSubnetCidr
AksSubnetCidr: AksSubnetCidr
}
}
module adlsGen2 './storage/storageaccount.template.bicep' = {
scope: rg
name: 'StorageAccount'
params: {
storageAccountName: storageAccountName
databricksPublicSubnetId: vnets.outputs.databricksPublicSubnetId
}
}
module adb './databricks/workspace.template.bicep' = {
scope: rg
name: 'DatabricksWorkspace'
params: {
vnetName: vnets.outputs.spokeVnetName
adbWorkspaceSkuTier: 'premium'
adbWorkspaceName: adbWorkspaceName
}
}
module hubFirewall './network/firewall.template.bicep' = {
scope: rg
name: 'HubFirewall'
params: {
firewallName: firewallName
publicIpAddressName: firewallPublicIpName
vnetName: vnets.outputs.hubVnetName
webappDestinationAddresses: webappDestinationAddresses
logBlobstorageDomains: logBlobstorageDomains
infrastructureDestinationAddresses: extendedInfraIp
sccRelayDomains: sccReplayDomain
metastoreDomains: metastoreDomains
eventHubEndpointDomains: eventHubEndpointDomain
artifactBlobStoragePrimaryDomains: artifactBlobStoragePrimaryDomains
dbfsBlobStrageDomain: array('${adb.outputs.databricks_dbfs_storage_accountName}.blob.${environment().suffixes.storage}')
clientPrivateIpAddr: clientpc.outputs.clientPrivateIpaddr
}
}
module routeTableUpdate './network/routetableFirewallRoute.template.bicep' = {
scope: rg
name: 'RouteTableUpdate'
params: {
routeTableName: fwRoutingTable
firewallPrivateIp: hubFirewall.outputs.firewallPrivateIp
}
}
module keyVault './keyvault/keyvault.template.bicep' = {
scope: rg
name: 'KeyVault'
params: {
keyVaultName: keyVaultName
objectId: myIdentity.outputs.mIdentityClientId
}
}
module clientpc './other/clientdevice.template.bicep' = {
name: 'ClientPC'
scope: rg
params: {
adminUsername: adminUsername
adminPassword: adminPassword
vnetName: vnets.outputs.hubVnetName
clientPcName: clientPcName
}
dependsOn: [
vnets
]
}
module loganalytics './monitor/loganalytics.template.bicep' = {
scope: rg
name: 'LogAnalytics'
}
module eventHubLogging './monitor/eventhub.template.bicep' = {
scope: rg
name: 'EventHub'
params: {
namespaceName: eHNameSpace
}
}
module privateEndPoints './network/privateendpoint.template.bicep' = {
scope: rg
name: 'PrivateEndPoints'
params: {
keyvaultName: keyVault.name
keyvaultPrivateLinkResource: keyVault.outputs.keyvault_id
privateLinkSubnetId: vnets.outputs.privatelinksubnet_id
storageAccountName: adlsGen2.name
storageAccountPrivateLinkResource: adlsGen2.outputs.storageaccount_id
eventHubName: eventHubLogging.outputs.eHName
eventHubPrivateLinkResource: eventHubLogging.outputs.eHNamespaceId
AmlName: aml.name
amlPrivateLinkResource: aml.outputs.amlId
vnetName: vnets.outputs.spokeVnetName
}
}
module createDatabricksCluster './databricks/deployment.template.bicep' = {
scope: rg
name: 'DatabricksCluster'
params: {
location: location
identity: myIdentity.outputs.mIdentityId
adb_workspace_url: adb.outputs.databricks_workspaceUrl
adb_workspace_id: adb.outputs.databricks_workspace_id
adb_secret_scope_name: adbAkvLinkName
akv_id: keyVault.outputs.keyvault_id
akv_uri: keyVault.outputs.keyvault_uri
LogAWkspId: loganalytics.outputs.logAnalyticsWkspId
LogAWkspKey: loganalytics.outputs.primarySharedKey
storageKey: adlsGen2.outputs.key1
evenHubKey: eventHubLogging.outputs.eHPConnString
}
}
module aml './aml/machinelearning.template.bicep' = {
scope: rg
name: 'MLWorkspace'
params: {
amlWorkspaceName: amlWorkspaceName
containerRegistryName: containerRegistryName
keyVaultIdentifierId: keyVault.outputs.keyvault_id
storageAccount: adlsGen2.outputs.storageaccount_id
applicationInsightsName: applicationInsightsName
}
}
module AksForAml './aks/aks-for-aml.template.bicep' = {
scope: rg
name: 'AksForAml'
params: {
amlWorkspaceName: aml.outputs.amlWkspName
sslLeafName: sslLeafName
aksAgentCount:aksAgentCount
aksAgentVMSize: aksAgentVMSize
aksAmlComputeName: aksAmlComputeName
}
}
// output resourceGroupName string = rg.name
// output keyVaultName string = keyVaultName
// output adbWorkspaceName string = adbWorkspaceName
// output storageAccountName string = storageAccountName
// output storageKey1 string = adlsGen2.outputs.key1
// output storageKey2 string = adlsGen2.outputs.key2
// output databricksWksp string = adb.outputs.databricks_workspace_id
// output databricks_workspaceUrl string = adb.outputs.databricks_workspaceUrl
// output keyvault_id string = keyVault.outputs.keyvault_id
// output keyvault_uri string = keyVault.outputs.keyvault_uri
// output logAnalyticsWkspId string = loganalytics.outputs.logAnalyticsWkspId
// output logAnalyticsprimarySharedKey string = loganalytics.outputs.primarySharedKey
// output logAnalyticssecondarySharedKey string = loganalytics.outputs.secondarySharedKey
// output eHNamespaceId string = eventHubLogging.outputs.eHNamespaceId
// output eHubNameId string = eventHubLogging.outputs.eHubNameId
// output eHAuthRulesId string = eventHubLogging.outputs.eHAuthRulesId
// output eHPConnString string = eventHubLogging.outputs.eHPConnString
// output dsOutputs object = createDatabricksCluster.outputs.patOutput
// output adbCluster object = createDatabricksCluster.outputs.adbCluster
// output amlProperties object = aml.outputs.amlProperties