Skip to content

Commit 1285f91

Browse files
committed
fix: updated variables; and condition
1 parent 94cf091 commit 1285f91

File tree

2 files changed

+21
-27
lines changed

2 files changed

+21
-27
lines changed

main.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ resource "databricks_sql_endpoint" "this" {
6868
}
6969

7070
resource "databricks_metastore_assignment" "this" {
71-
count = length(var.external_metastore_id) != 0 ? 1 : 0
71+
count = alltrue([var.assign_unity_catalog_metastore, length(var.external_metastore_id) != 0]) ? 1 : 0
7272

73-
workspace_id = var.workspace_id
74-
metastore_id = var.external_metastore_id
73+
workspace_id = var.workspace_id
74+
metastore_id = var.external_metastore_id
75+
default_catalog_name = "hive_metastore"
7576
}

variables.tf

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -72,30 +72,6 @@ variable "suffix" {
7272
default = ""
7373
}
7474

75-
variable "external_metastore_id" {
76-
type = string
77-
description = "Unity Catalog Metastore Id that is located in separate environment. Provide this value to associate Databricks Workspace with target Metastore"
78-
default = ""
79-
validation {
80-
condition = length(var.external_metastore_id) == 36 || length(var.external_metastore_id) == 0
81-
error_message = "UUID has to be either in nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn format or empty string"
82-
}
83-
}
84-
85-
variable "metastore_grants" {
86-
type = map(list(string))
87-
description = "Permissions to give on metastore to group"
88-
default = {}
89-
validation {
90-
condition = values(var.metastore_grants) != null ? alltrue([
91-
for item in toset(flatten([for group, params in var.metastore_grants : params if params != null])) : contains([
92-
"CREATE_CATALOG", "CREATE_EXTERNAL_LOCATION", "CREATE_SHARE", "CREATE_RECIPIENT", "CREATE_PROVIDER"
93-
], item)
94-
]) : true
95-
error_message = "Metastore permission validation. The only possible values for permissions are: CREATE_CATALOG, CREATE_EXTERNAL_LOCATION, CREATE_SHARE, CREATE_RECIPIENT, CREATE_PROVIDER"
96-
}
97-
}
98-
9975
variable "sp_client_id_secret_name" {
10076
type = string
10177
description = "The name of Azure Key Vault secret that contains ClientID of Service Principal to access in Azure Key Vault"
@@ -151,6 +127,23 @@ variable "mountpoints" {
151127
default = {}
152128
}
153129

130+
# Unity Catalog Metastore assignment variables
131+
variable "assign_unity_catalog_metastore" {
132+
type = bool
133+
description = "Boolean flag provides an ability to assign Unity Catalog Metastore to this Workspace"
134+
default = false
135+
}
136+
137+
variable "external_metastore_id" {
138+
type = string
139+
description = "Unity Catalog Metastore Id that is located in separate environment. Provide this value to associate Databricks Workspace with target Metastore"
140+
default = ""
141+
validation {
142+
condition = anytrue([length(var.external_metastore_id) == 36, length(var.external_metastore_id) == 0])
143+
error_message = "UUID has to be either in nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn format or empty string"
144+
}
145+
}
146+
154147
variable "custom_cluster_policies" {
155148
type = list(object({
156149
name = string

0 commit comments

Comments
 (0)