forked from databricks/terraform-databricks-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
69 lines (57 loc) · 1.54 KB
/
main.tf
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
/**
* Azure Databricks workspace in custom VNet
*
* Module creates:
* * Resource group with random prefix
* * Tags, including `Owner`, which is taken from `az account show --query user`
* * VNet with public and private subnet
* * Databricks workspace
*/
provider "azurerm" {
features {}
}
provider "random" {
}
resource "random_string" "naming" {
special = false
upper = false
length = 6
}
data "azurerm_client_config" "current" {
}
data "external" "me" {
program = ["az", "account", "show", "--query", "user"]
}
locals {
// dltp - databricks labs terraform provider
prefix = join("-", [var.workspace_prefix, "${random_string.naming.result}"])
location = var.rglocation
cidr = var.spokecidr
dbfsname = join("", [var.dbfs_prefix, "${random_string.naming.result}"]) // dbfs name must not have special chars
// tags that are propagated down to all resources
tags = {
Environment = "Testing"
Owner = lookup(data.external.me.result, "name")
Epoch = random_string.naming.result
}
}
resource "azurerm_resource_group" "this" {
name = "adb-dev-${local.prefix}-rg"
location = local.location
tags = local.tags
}
output "arm_client_id" {
value = data.azurerm_client_config.current.client_id
}
output "arm_subscription_id" {
value = data.azurerm_client_config.current.subscription_id
}
output "arm_tenant_id" {
value = data.azurerm_client_config.current.tenant_id
}
output "azure_region" {
value = local.location
}
output "resource_group" {
value = azurerm_resource_group.this.name
}