Skip to content

Commit a7724f2

Browse files
committed
initial commit
1 parent c4bd78a commit a7724f2

File tree

10 files changed

+138
-72
lines changed

10 files changed

+138
-72
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export TF_AZURE_CONTAINER=tfstate # Output of remote_state.sh
7676
export ARM_ACCESS_KEY=xxxxxxxxxx # Output of remote_state.sh
7777
```
7878

79-
- Update [main.tf](examples/sample/main.tf) file with required values.
79+
- Update [main.tf](examples/azure_databricks_new_vnet/main.tf) file with required values.
8080

8181
- Run and verify the output before deploying:
8282
```
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module "vnet" {
2+
source = "[email protected]:tomarv2/terraform-azure-vnet.git?ref=v0.0.1"
3+
4+
resource_group_name = "demo-resource_group"
5+
location = "westus2"
6+
cidr_block = ["10.7.7.0/24"]
7+
# ---------------------------------------------
8+
# Note: Do not change teamid and prjid once set.
9+
teamid = var.teamid
10+
prjid = var.prjid
11+
}
12+
13+
module "azure_databricks" {
14+
source = "../../"
15+
deploy_resource_group = false
16+
resource_group_name = "demo-resource_group"
17+
custom_parameters = {
18+
virtual_network_id = module.vnet.vnet_id
19+
}
20+
# ---------------------------------------------
21+
# Note: Do not change teamid and prjid once set.
22+
teamid = var.teamid
23+
prjid = var.prjid
24+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
output "resource_group_name" {
2+
description = "Resource Group name"
3+
value = module.azure_databricks.resource_group_name
4+
}
5+
6+
output "databricks_host" {
7+
description = "Databricks hosts"
8+
value = module.azure_databricks.databricks_host
9+
}
10+
11+
output "databricks_workspace_id" {
12+
description = "Databricks workspace id"
13+
value = module.azure_databricks.databricks_workspace_id
14+
}
15+
16+
output "databricks_managed_resource_group_name" {
17+
description = "Databricks managed_resource group name"
18+
value = module.azure_databricks.managed_resource_group_name
19+
}
20+
21+
output "databricks_sku" {
22+
value = module.azure_databricks.databricks_sku
23+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
variable "teamid" {
22
description = "(Required) Name of the team/group e.g. devops, dataengineering. Should not be changed after running 'tf apply'"
33
type = string
4+
default = "demo"
45
}
56

67
variable "prjid" {
78
description = "(Required) Name of the project/stack e.g: mystack, nifieks, demoaci. Should not be changed after running 'tf apply'"
89
type = string
10+
default = "databricks"
911
}

main.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,15 @@ data "azurerm_client_config" "current" {
44
data "external" "current_user" {
55
program = ["az", "account", "show", "--query", "user"]
66
}
7+
8+
module "resource_group" {
9+
source = "[email protected]:tomarv2/terraform-azure-resource-group.git?ref=v0.0.3"
10+
11+
deploy_resource_group = var.deploy_resource_group != false ? true : false
12+
resource_group_name = var.resource_group_name != null ? var.resource_group_name : "${var.teamid}-${var.prjid}"
13+
14+
# ------------------------------------------------
15+
# Do not change the teamid, prjid once set.
16+
teamid = var.teamid
17+
prjid = var.prjid
18+
}

outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ output "databricks_workspace_id" {
1717
description = "databricks workspace id"
1818
value = azurerm_databricks_workspace.this.workspace_id
1919
}
20+
21+
output "databricks_sku" {
22+
value = azurerm_databricks_workspace.this.sku
23+
}

resource_group.tf

Lines changed: 0 additions & 7 deletions
This file was deleted.

variables.tf

Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,9 @@ variable "prjid" {
99
}
1010

1111
variable "region" {
12-
description = "default Azure region"
13-
type = string
14-
default = "westeurope"
15-
}
16-
17-
variable "databricks_account_username" {
18-
description = "databricks account username"
19-
type = string
20-
}
21-
variable "databricks_account_password" {
22-
description = "databricks account password"
23-
type = string
24-
}
25-
26-
variable "databricks_account_id" {
27-
description = "External ID provided by third party."
12+
description = " The region where the resources are created"
2813
type = string
14+
default = "westus2"
2915
}
3016

3117
resource "random_string" "naming" {
@@ -35,7 +21,7 @@ resource "random_string" "naming" {
3521
}
3622

3723
locals {
38-
suffix = random_string.naming.result
24+
prefix = random_string.naming.result
3925
}
4026

4127
variable "resource_group_name" {
@@ -45,56 +31,67 @@ variable "resource_group_name" {
4531
}
4632

4733
variable "workspace_name" {
48-
description = "Databricks workspace name"
34+
description = "Specifies the name of the Databricks Workspace resource. Changing this forces a new resource to be created"
4935
default = null
5036
type = string
5137
}
5238

5339
variable "sku" {
54-
description = "Databricks sku"
55-
default = "premium"
40+
description = "The sku to use for the Databricks Workspace. Possible values are standard, premium, or trial. Changing this can force a new resource to be created in some circumstances"
41+
default = "standard"
5642
type = string
5743
}
5844

59-
60-
variable "subscription_id" {
61-
description = "Azure subscription Id"
62-
type = string
45+
variable "custom_tags" {
46+
type = any
47+
description = "Extra custom tags"
48+
default = null
6349
}
6450

65-
variable "client_id" {
66-
description = "Azure client Id"
67-
type = string
51+
variable "deploy_resource_group" {
52+
description = "feature flag to deploy this resource or not"
53+
type = bool
54+
default = false
6855
}
6956

70-
variable "client_secret" {
71-
description = "Azure client secret"
72-
type = string
57+
variable "infrastructure_encryption_enabled" {
58+
description = "Is the Databricks File System root file system enabled with a secondary layer of encryption with platform managed keys? Possible values are true or false. Defaults to false. This field is only valid if the Databricks Workspace sku is set to premium. Changing this forces a new resource to be created"
59+
default = false
60+
type = bool
7361
}
7462

75-
variable "tenant_id" {
76-
description = "Azure tenant Id"
77-
type = string
63+
variable "public_network_access_enabled" {
64+
description = "Allow public access for accessing workspace. Set value to false to access workspace only via private link endpoint. Possible values include true or false. Defaults to true. Changing this forces a new resource to be created"
65+
default = false
66+
type = bool
7867
}
7968

80-
variable "custom_tags" {
69+
variable "custom_parameters" {
70+
description = "https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/databricks_workspace"
8171
type = any
82-
description = "Extra custom tags"
8372
default = null
8473
}
8574

86-
variable "deploy_resource_group" {
87-
description = "feature flag to deploy this resource or not"
88-
type = bool
75+
variable "customer_managed_key_enabled" {
76+
description = "Is the workspace enabled for customer managed key encryption? If true this enables the Managed Identity for the managed storage account. Possible values are true or false. Defaults to false. This field is only valid if the Databricks Workspace sku is set to premium. Changing this forces a new resource to be created"
8977
default = false
78+
type = bool
9079
}
9180

92-
resource "random_string" "naming" {
93-
special = false
94-
upper = false
95-
length = 3
81+
variable "load_balancer_backend_address_pool_id" {
82+
description = "Resource ID of the Outbound Load balancer Backend Address Pool for Secure Cluster Connectivity (No Public IP) workspace. Changing this forces a new resource to be created"
83+
default = null
84+
type = string
9685
}
9786

98-
locals {
99-
prefix = random_string.naming.result
100-
}
87+
variable "managed_services_cmk_key_vault_key_id" {
88+
description = "Customer managed encryption properties for the Databricks Workspace managed resources(e.g. Notebooks and Artifacts). Changing this forces a new resource to be created."
89+
default = null
90+
type = string
91+
}
92+
93+
variable "network_security_group_rules_required" {
94+
description = "Does the data plane (clusters) to control plane communication happen over private link endpoint only or publicly? Possible values AllRules, NoAzureDatabricksRules or NoAzureServiceRules. Required when public_network_access_enabled is set to false. Changing this forces a new resource to be created"
95+
default = null
96+
type = string
97+
}

versions.tf

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,12 @@ terraform {
1111
random = {
1212
version = "~> 3.1"
1313
}
14-
time = {
15-
version = "~> 0.7"
16-
}
1714
external = {
1815
version = "~> 2.2"
1916
}
2017
}
2118
}
2219

23-
provider "databricks" {
24-
host = "https://accounts.cloud.databricks.com"
25-
username = var.databricks_account_username
26-
password = var.databricks_account_password
27-
}
28-
2920
provider "azurerm" {
3021
features {}
31-
subscription_id = var.subscription_id
32-
client_id = var.client_id
33-
client_secret = var.client_secret
34-
tenant_id = var.tenant_id
3522
}

workspace.tf

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,32 @@
11
resource "azurerm_databricks_workspace" "this" {
2-
name = var.workspace_name != null ? var.workspace_name : "${var.teamid}-${var.prjid}"
3-
resource_group_name = azurerm_resource_group.this.name
4-
location = azurerm_resource_group.this.location
5-
sku = var.sku
6-
managed_resource_group_name = "${local.prefix}-workspace-rg"
7-
tags = local.shared_tags
2+
name = var.workspace_name != null ? var.workspace_name : "${var.teamid}-${var.prjid}"
3+
resource_group_name = var.deploy_resource_group != false ? join("", module.resource_group.*.resource_group_name) : var.resource_group_name
4+
location = var.region
5+
sku = var.sku
6+
managed_resource_group_name = "${local.prefix}-workspace-rg"
7+
infrastructure_encryption_enabled = var.infrastructure_encryption_enabled
8+
customer_managed_key_enabled = var.customer_managed_key_enabled
9+
load_balancer_backend_address_pool_id = var.load_balancer_backend_address_pool_id
10+
managed_services_cmk_key_vault_key_id = var.managed_services_cmk_key_vault_key_id
11+
public_network_access_enabled = var.public_network_access_enabled
12+
network_security_group_rules_required = var.network_security_group_rules_required
13+
dynamic "custom_parameters" {
14+
for_each = var.custom_parameters != null ? [var.custom_parameters] : []
15+
content {
16+
machine_learning_workspace_id = lookup(custom_parameters.value, "machine_learning_workspace_id", null)
17+
nat_gateway_name = lookup(custom_parameters.value, "nat_gateway_name", null)
18+
public_ip_name = lookup(custom_parameters.value, "public_ip_name", null)
19+
no_public_ip = lookup(custom_parameters.value, "no_public_ip", null)
20+
public_subnet_name = lookup(custom_parameters.value, "public_subnet_name", null)
21+
public_subnet_network_security_group_association_id = lookup(custom_parameters.value, "public_subnet_network_security_group_association_id", null)
22+
private_subnet_name = lookup(custom_parameters.value, "private_subnet_name", null)
23+
private_subnet_network_security_group_association_id = lookup(custom_parameters.value, "private_subnet_network_security_group_association_id", null)
24+
storage_account_name = lookup(custom_parameters.value, "storage_account_name", null)
25+
storage_account_sku_name = lookup(custom_parameters.value, "storage_account_sku_name", null)
26+
virtual_network_id = lookup(custom_parameters.value, "virtual_network_id", null)
27+
vnet_address_prefix = lookup(custom_parameters.value, "vnet_address_prefix", null)
28+
29+
}
30+
}
31+
tags = var.custom_tags != null ? merge(var.custom_tags, local.shared_tags) : local.shared_tags
832
}

0 commit comments

Comments
 (0)