2020-06-05 19:10:41 +03:00
|
|
|
provider "azurerm" {
|
|
|
|
version = "~> 2.3"
|
|
|
|
features {}
|
|
|
|
}
|
|
|
|
|
|
|
|
locals {
|
2020-06-18 17:16:55 +03:00
|
|
|
resource_group = data.azurerm_resource_group.main
|
|
|
|
databricks_vnet_id = data.azurerm_virtual_network.main.id
|
|
|
|
databricks_private_snet_name = data.azurerm_subnet.private.name
|
|
|
|
databricks_public_snet_name = data.azurerm_subnet.public.name
|
|
|
|
log_analytics_workspace_id = data.azurerm_log_analytics_workspace.main.id
|
|
|
|
diagnostics_storage_account_id = data.azurerm_storage_account.main.id
|
|
|
|
diagnostics_script_path = var.diagnostics_script_path == "" ? "${path.module}/scripts/diagnostics.sh" : var.diagnostics_script_path
|
2020-06-05 19:10:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
module "azurerm_naming" {
|
2020-06-08 14:05:33 +03:00
|
|
|
source = "git::https://github.com/Azure/terraform-azurerm-naming"
|
2020-06-05 19:10:41 +03:00
|
|
|
prefix = var.prefix
|
|
|
|
suffix = var.suffix
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_databricks_workspace" "main" {
|
|
|
|
name = module.azurerm_naming.databricks_workspace.name_unique
|
2020-06-18 17:16:55 +03:00
|
|
|
resource_group_name = local.resource_group.name
|
|
|
|
location = local.resource_group.location
|
2020-06-08 14:05:33 +03:00
|
|
|
sku = var.databricks_workspace_sku
|
2020-06-18 17:16:55 +03:00
|
|
|
|
|
|
|
custom_parameters {
|
|
|
|
no_public_ip = var.no_public_ip
|
|
|
|
virtual_network_id = local.databricks_vnet_id
|
|
|
|
public_subnet_name = local.databricks_public_snet_name
|
|
|
|
private_subnet_name = local.databricks_private_snet_name
|
|
|
|
}
|
2020-06-05 19:10:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "null_resource" "main" {
|
|
|
|
triggers = {
|
2020-06-18 17:16:55 +03:00
|
|
|
log_analytics_id = local.log_analytics_workspace_id
|
|
|
|
diagnostics_storage_account_id = local.diagnostics_storage_account_id
|
2020-06-05 19:10:41 +03:00
|
|
|
}
|
|
|
|
provisioner "local-exec" {
|
2020-06-18 19:21:17 +03:00
|
|
|
command = "${local.diagnostics_script_path} ${local.resource_group.name} ${local.log_analytics_workspace_id} ${local.diagnostics_storage_account_id} ${azurerm_databricks_workspace.main.id}"
|
2020-06-05 19:10:41 +03:00
|
|
|
}
|
2020-06-25 10:07:47 +03:00
|
|
|
|
|
|
|
depends_on = [azurerm_databricks_workspace.main]
|
2020-06-05 19:10:41 +03:00
|
|
|
}
|