Skip to content

Commit e3cd612

Browse files
authored
Update adb-private-links to use azurerm v4 (#162)
Signed-off-by: Niko <[email protected]>
1 parent db513b6 commit e3cd612

File tree

9 files changed

+78
-83
lines changed

9 files changed

+78
-83
lines changed

examples/adb-private-links/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ With this deployment, traffic from user client to webapp (notebook UI), backend
2626

2727
| Name | Description | Type | Default | Required |
2828
| ---------------- | ----------- | ----------- | --------------- | :------: |
29+
| subscription_id | n/a | `string` | | yes |
2930
| hubcidr | n/a | `string` | "10.178.0.0/20" | yes |
3031
| spokecidr | n/a | `string` | "10.179.0.0/20" | yes |
3132
| no\_public\_ip | n/a | `bool` | `true` | yes |
@@ -44,6 +45,8 @@ With this deployment, traffic from user client to webapp (notebook UI), backend
4445
| arm\_subscription\_id | n/a |
4546
| arm\_tenant\_id | n/a |
4647
| azure\_region | n/a |
48+
| azure\_resource_group | n/a |
4749
| databricks\_azure\_workspace\_resource\_id | n/a |
4850
| resource\_group | n/a |
51+
| workspace\_id | n/a |
4952
| workspace\_url | n/a |

examples/adb-private-links/main.tf

+1-38
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
/**
2-
* Azure Databricks workspace in custom VNet
3-
*
4-
* Module creates:
5-
* * Resource group with random prefix
6-
* * Tags, including `Owner`, which is taken from `az account show --query user`
7-
* * VNet with public and private subnet
8-
* * Databricks workspace
9-
*/
10-
provider "azurerm" {
11-
features {}
12-
}
13-
14-
provider "random" {
15-
}
16-
171
resource "random_string" "naming" {
182
special = false
193
upper = false
@@ -28,7 +12,6 @@ data "external" "me" {
2812
}
2913

3014
locals {
31-
// dltp - databricks labs terraform provider
3215
prefix = join("-", [var.workspace_prefix, "${random_string.naming.result}"])
3316
location = var.rglocation
3417
cidr = var.spokecidr
@@ -46,24 +29,4 @@ resource "azurerm_resource_group" "this" {
4629
name = "adb-dev-${local.prefix}-rg"
4730
location = local.location
4831
tags = local.tags
49-
}
50-
51-
output "arm_client_id" {
52-
value = data.azurerm_client_config.current.client_id
53-
}
54-
55-
output "arm_subscription_id" {
56-
value = data.azurerm_client_config.current.subscription_id
57-
}
58-
59-
output "arm_tenant_id" {
60-
value = data.azurerm_client_config.current.tenant_id
61-
}
62-
63-
output "azure_region" {
64-
value = local.location
65-
}
66-
67-
output "resource_group" {
68-
value = azurerm_resource_group.this.name
69-
}
32+
}

examples/adb-private-links/outputs.tf

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
output "azure_resource_group_id" {
2+
description = "ID of the created Azure resource group"
3+
value = azurerm_resource_group.this.id
4+
}
5+
6+
output "workspace_id" {
7+
description = "The Databricks workspace ID"
8+
value = azurerm_databricks_workspace.this.workspace_id
9+
}
10+
11+
output "workspace_url" {
12+
description = "The Databricks workspace URL"
13+
value = azurerm_databricks_workspace.this.workspace_url
14+
}
15+
16+
output "arm_client_id" {
17+
description = "**Depricated**"
18+
value = data.azurerm_client_config.current.client_id
19+
}
20+
21+
output "arm_subscription_id" {
22+
description = "**Depricated**"
23+
value = data.azurerm_client_config.current.subscription_id
24+
}
25+
26+
output "arm_tenant_id" {
27+
description = "**Depricated**"
28+
value = data.azurerm_client_config.current.tenant_id
29+
}
30+
31+
output "azure_region" {
32+
description = "**Depricated**"
33+
value = local.location
34+
}
35+
36+
output "resource_group" {
37+
description = "**Depricated**"
38+
value = azurerm_resource_group.this.name
39+
}
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
terraform {
2+
required_providers {
3+
databricks = {
4+
source = "databricks/databricks"
5+
version = ">=1.52.0"
6+
}
7+
azurerm = {
8+
source = "hashicorp/azurerm"
9+
version = ">=4.0.0"
10+
}
11+
random = {
12+
source = "hashicorp/random"
13+
}
14+
}
15+
}
16+
17+
provider "azurerm" {
18+
subscription_id = var.subscription_id
19+
features {}
20+
}

examples/adb-private-links/terraform.tfvars

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
subscription_id = "<your Azure Subscription ID here>"
12
hubcidr = "10.178.0.0/20"
23
spokecidr = "10.179.0.0/20"
3-
no_public_ip = true
44
rglocation = "southeastasia"
55
metastoreip = "40.78.233.2"
66
dbfs_prefix = "dbfs"

examples/adb-private-links/variables.tf

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
variable "subscription_id" {
2+
type = string
3+
description = "Azure Subscription ID to deploy the workspace into"
4+
}
5+
16
variable "hubcidr" {
27
type = string
38
default = "10.178.0.0/20"
@@ -8,11 +13,6 @@ variable "spokecidr" {
813
default = "10.179.0.0/20"
914
}
1015

11-
variable "no_public_ip" {
12-
type = bool
13-
default = true
14-
}
15-
1616
variable "rglocation" {
1717
type = string
1818
default = "southeastasia"

examples/adb-private-links/versions.tf

-14
This file was deleted.

examples/adb-private-links/vnet.tf

+8-11
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ resource "azurerm_network_security_rule" "azfrontdoor" {
4040
resource_group_name = azurerm_resource_group.this.name
4141
network_security_group_name = azurerm_network_security_group.this.name
4242
}
43+
4344
resource "azurerm_subnet" "public" {
4445
name = "${local.prefix}-public"
4546
resource_group_name = azurerm_resource_group.this.name
@@ -73,8 +74,7 @@ resource "azurerm_subnet" "private" {
7374
virtual_network_name = azurerm_virtual_network.this.name
7475
address_prefixes = [cidrsubnet(local.cidr, 3, 1)]
7576

76-
enforce_private_link_endpoint_network_policies = true
77-
enforce_private_link_service_network_policies = true
77+
private_endpoint_network_policies = "Enabled"
7878

7979
delegation {
8080
name = "databricks"
@@ -95,16 +95,14 @@ resource "azurerm_subnet_network_security_group_association" "private" {
9595
network_security_group_id = azurerm_network_security_group.this.id
9696
}
9797

98-
9998
resource "azurerm_subnet" "plsubnet" {
100-
name = "${local.prefix}-privatelink"
101-
resource_group_name = azurerm_resource_group.this.name
102-
virtual_network_name = azurerm_virtual_network.this.name
103-
address_prefixes = [cidrsubnet(local.cidr, 3, 2)]
104-
enforce_private_link_endpoint_network_policies = true // set to true to disable subnet policy
99+
name = "${local.prefix}-privatelink"
100+
resource_group_name = azurerm_resource_group.this.name
101+
virtual_network_name = azurerm_virtual_network.this.name
102+
address_prefixes = [cidrsubnet(local.cidr, 3, 2)]
103+
private_endpoint_network_policies = "Enabled"
105104
}
106105

107-
108106
resource "azurerm_virtual_network" "hubvnet" {
109107
name = "${local.prefix}-hub-vnet"
110108
location = azurerm_resource_group.this.location
@@ -121,7 +119,6 @@ resource "azurerm_subnet" "hubfw" {
121119
address_prefixes = [cidrsubnet(var.hubcidr, 3, 0)]
122120
}
123121

124-
125122
resource "azurerm_virtual_network_peering" "hubvnet" {
126123
name = "peerhubtospoke"
127124
resource_group_name = azurerm_resource_group.this.name
@@ -134,4 +131,4 @@ resource "azurerm_virtual_network_peering" "spokevnet" {
134131
resource_group_name = azurerm_resource_group.this.name
135132
virtual_network_name = azurerm_virtual_network.this.name
136133
remote_virtual_network_id = azurerm_virtual_network.hubvnet.id
137-
}
134+
}

examples/adb-private-links/workspace.tf

+1-14
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ resource "azurerm_databricks_workspace" "this" {
77
public_network_access_enabled = false //use private endpoint
88
network_security_group_rules_required = "NoAzureDatabricksRules" //use private endpoint
99
customer_managed_key_enabled = true
10-
//infrastructure_encryption_enabled = true
1110
custom_parameters {
12-
no_public_ip = var.no_public_ip
1311
virtual_network_id = azurerm_virtual_network.this.id
1412
private_subnet_name = azurerm_subnet.private.name
1513
public_subnet_name = azurerm_subnet.public.name
@@ -22,15 +20,4 @@ resource "azurerm_databricks_workspace" "this" {
2220
azurerm_subnet_network_security_group_association.public,
2321
azurerm_subnet_network_security_group_association.private
2422
]
25-
}
26-
27-
output "databricks_azure_workspace_resource_id" {
28-
// The ID of the Databricks Workspace in the Azure management plane.
29-
value = azurerm_databricks_workspace.this.id
30-
}
31-
32-
output "workspace_url" {
33-
// The workspace URL which is of the format 'adb-{workspaceId}.{random}.azuredatabricks.net'
34-
// this is not named as DATABRICKS_HOST, because it affect authentication
35-
value = "https://${azurerm_databricks_workspace.this.workspace_url}/"
36-
}
23+
}

0 commit comments

Comments
 (0)