Skip to content

Commit 501a4ce

Browse files
authored
Fix: Quick fix to solve some issues with adb-lakehouse example (#59)
* Fix: Quick fix to solve some issues with adb-lakehouse example * Fix: Quick fix to solve some issues with adb-lakehouse example
1 parent fba601a commit 501a4ce

File tree

15 files changed

+52
-10
lines changed

15 files changed

+52
-10
lines changed

examples/adb-lakehouse/README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Lakehouse terraform blueprints
22

33
This example contains Terraform code used to provision a Lakehouse platform using the [adb-lakehouse module](../../modules/adb-lakehouse).
4-
It also contains Terraform code to create Unity Catalog metastore and multiple UC resources, it also creates principals in Databricks account and assign them to Databricks workspace.
4+
It also contains Terraform code to create the following:
5+
* Unity Catalog metastore
6+
* Unity Catalog resources: Catalog, Schema, table, storage credential and external location
7+
* New principals in the Databricks account and assign them to the Databricks workspace.
58

69
## Deployed resources
710

examples/adb-lakehouse/main.tf

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ module "adb-lakehouse-uc-metastore" {
2626
access_connector_name = var.access_connector_name
2727
metastore_id = module.adb-lakehouse-uc-metastore.metastore_id
2828
workspace_id = module.adb-lakehouse.workspace_id
29+
metastore_admins = var.metastore_admins
2930
providers = {
3031
databricks = databricks.workspace
3132
}
@@ -48,8 +49,10 @@ module "adb-lakehouse-data-assets" {
4849
environment_name = var.environment_name
4950
storage_credential_name = var.access_connector_name
5051
metastore_id = module.adb-lakehouse-uc-metastore.metastore_id
52+
access_connector_id = module.adb-lakehouse.access_connector_principal_id
5153
landing_external_location_name = var.landing_external_location_name
5254
landing_adls_path = var.landing_adls_path
55+
landing_adls_rg = var.landing_adls_rg
5356
metastore_admins = var.metastore_admins
5457
providers = {
5558
databricks = databricks.workspace

examples/adb-lakehouse/providers.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ provider "databricks" {
1111

1212
provider "databricks" {
1313
alias = "workspace"
14-
host = "<workspace_url>"
14+
host = module.adb-lakehouse.workspace_url
1515
}

examples/adb-lakehouse/variables.tf

+5
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ variable "landing_adls_path" {
109109
description = "The ADLS path of the landing zone"
110110
}
111111

112+
variable "landing_adls_rg" {
113+
type = string
114+
description = "The resource group name of the landing zone"
115+
}
116+
112117
variable "metastore_admins" {
113118
type = list(string)
114119
description = "list of principals: service principals or groups that have metastore admin privileges"

examples/adb-lakehouse/versions.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
terraform {
22
required_providers {
33
azurerm = {
4-
source = "hashicorp/azurerm"
4+
source = "hashicorp/azurerm"
55
}
66
databricks = {
7-
source = "databricks/databricks"
7+
source = "databricks/databricks"
88
}
99
}
1010
}

modules/adb-lakehouse-uc/account-principals/providers.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
terraform {
22
required_providers {
33
azurerm = {
4-
source = "hashicorp/azurerm"
4+
source = "hashicorp/azurerm"
55
}
66
databricks = {
77
source = "databricks/databricks"

modules/adb-lakehouse-uc/uc-data-assets/providers.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
terraform {
22
required_providers {
33
azurerm = {
4-
source = "hashicorp/azurerm"
4+
source = "hashicorp/azurerm"
55
}
66
databricks = {
77
source = "databricks/databricks"

modules/adb-lakehouse-uc/uc-data-assets/uc-data-assets.tf

+12
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,20 @@ resource "databricks_schema" "bronze_source1-schema" {
1212
force_destroy = true
1313
}
1414

15+
data "azurerm_storage_account" "ext_storage" {
16+
name = var.landing_external_location_name
17+
resource_group_name = var.landing_adls_rg
18+
}
19+
20+
resource "azurerm_role_assignment" "ext_storage" {
21+
scope = data.azurerm_storage_account.ext_storage.id
22+
role_definition_name = "Storage Blob Data Contributor"
23+
principal_id = var.access_connector_id
24+
}
25+
1526
resource "databricks_external_location" "landing-external-location" {
1627
name = var.landing_external_location_name
1728
url = var.landing_adls_path
1829
credential_name = var.storage_credential_name
30+
comment = "Created by TF"
1931
}

modules/adb-lakehouse-uc/uc-data-assets/variables.tf

+10
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ variable "landing_adls_path" {
1313
description = "The ADLS path of the landing zone"
1414
}
1515

16+
variable "landing_adls_rg" {
17+
type = string
18+
description = "The resource group name of the landing zone"
19+
}
20+
1621
variable "storage_credential_name" {
1722
type = string
1823
description = "the name of the storage credential"
@@ -27,3 +32,8 @@ variable "metastore_admins" {
2732
type = list(string)
2833
description = "list of principals: service principals or groups that have metastore admin privileges"
2934
}
35+
36+
variable "access_connector_id" {
37+
type = string
38+
description = "the id of the access connector"
39+
}

modules/adb-lakehouse-uc/uc-metastore/providers.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
terraform {
22
required_providers {
33
azurerm = {
4-
source = "hashicorp/azurerm"
4+
source = "hashicorp/azurerm"
55
}
66
databricks = {
77
source = "databricks/databricks"

modules/adb-lakehouse-uc/uc-metastore/variables.tf

+4
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@ variable "workspace_id" {
2929
description = "the id of the workspace"
3030
}
3131

32+
variable "metastore_admins" {
33+
type = list(string)
34+
description = "list of principals: service principals or groups that have metastore admin privileges"
35+
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
resource "azurerm_data_factory" "adf" {
22
name = var.data_factory_name
33
location = var.location
4-
resource_group_name = var.spoke_resource_group_name
4+
resource_group_name = azurerm_resource_group.this.name
55
tags = var.tags
66
}

modules/adb-lakehouse/key_vault.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
resource "azurerm_key_vault" "example" {
22
name = var.key_vault_name
33
location = var.location
4-
resource_group_name = var.spoke_resource_group_name
4+
resource_group_name = azurerm_resource_group.this.name
55
enabled_for_disk_encryption = true
66
tenant_id = data.azurerm_client_config.current.tenant_id
77
soft_delete_retention_days = 7

modules/adb-lakehouse/outputs.tf

+5
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,9 @@ output "workspace_url" {
4141
output "access_connector_id" {
4242
value = azurerm_databricks_access_connector.access_connector.id
4343
description = "the id of the access connector"
44+
}
45+
46+
output "access_connector_principal_id" {
47+
value = azurerm_databricks_access_connector.access_connector.identity[0].principal_id
48+
description = "The Principal ID of the System Assigned Managed Service Identity that is configured on this Access Connector"
4449
}

modules/adb-lakehouse/versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
terraform {
22
required_providers {
33
azurerm = {
4-
source = "hashicorp/azurerm"
4+
source = "hashicorp/azurerm"
55
}
66
}
77
}

0 commit comments

Comments
 (0)