Skip to content

Commit 2838782

Browse files
committed
fix: workspace assignment
1 parent eb05973 commit 2838782

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

main.tf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
locals {
2-
# This optional suffix is added to the end of resource names.
2+
# This optional suffix is added to the end of resource names.
33
suffix = length(var.suffix) == 0 ? "" : "-${var.suffix}"
44

55
databricks_metastore_name = var.custom_databricks_metastore_name == null ? "meta-${var.project}-${var.env}-${var.location}${local.suffix}" : var.custom_databricks_metastore_name
@@ -56,6 +56,14 @@ resource "databricks_metastore_data_access" "this" {
5656
is_default = true
5757
}
5858

59+
resource "databricks_metastore_assignment" "this" {
60+
count = anytrue([!var.create_metastore, length(var.external_metastore_id) == 0]) ? 0 : 1
61+
62+
workspace_id = var.workspace_id
63+
metastore_id = length(var.external_metastore_id) == 0 ? databricks_metastore.this[0].id : var.external_metastore_id
64+
default_catalog_name = "hive_metastore"
65+
}
66+
5967
# Catalog
6068
resource "databricks_catalog" "this" {
6169
for_each = alltrue([!var.create_metastore, length(var.external_metastore_id) == 0]) ? {} : var.catalog

variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ variable "suffix" {
1919
default = ""
2020
}
2121

22+
variable "workspace_id" {
23+
type = string
24+
description = "Id of Azure Databricks workspace"
25+
}
26+
2227
# Unity Catalog variables
2328
variable "create_metastore" {
2429
type = bool

0 commit comments

Comments
 (0)