Skip to content

Commit 868ce29

Browse files
author
oleh_mykolaishyn
committed
feat: workspace bindings support; catalog's managed locations support
1 parent 1e155e8 commit 868ce29

File tree

3 files changed

+49
-23
lines changed

3 files changed

+49
-23
lines changed

main.tf

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ resource "databricks_grants" "metastore" {
2323
resource "databricks_catalog" "this" {
2424
for_each = var.catalog
2525

26-
metastore_id = var.metastore_id
27-
name = each.key
28-
owner = each.value.catalog_owner
29-
comment = lookup(each.value, "catalog_comment", "default comment")
30-
properties = merge(lookup(each.value, "catalog_properties", {}), { env = var.env })
31-
force_destroy = true
26+
metastore_id = var.metastore_id
27+
name = each.key
28+
owner = each.value.catalog_owner
29+
storage_root = each.value.catalog_storage_root
30+
isolation_mode = each.value.catalog_isolation_mode
31+
comment = lookup(each.value, "catalog_comment", "default comment")
32+
properties = lookup(each.value, "catalog_properties", {})
33+
force_destroy = true
3234
}
3335

3436
# Catalog grants
@@ -72,7 +74,7 @@ resource "databricks_schema" "this" {
7274
name = each.value.schema
7375
owner = each.value.owner
7476
comment = each.value.comment
75-
properties = merge(each.value.properties, { env = var.env })
77+
properties = each.value.properties
7678
force_destroy = true
7779
}
7880

@@ -99,3 +101,14 @@ resource "databricks_grants" "schema" {
99101
privileges = each.value.permission
100102
}
101103
}
104+
105+
# ISOLATED Catalogs binding
106+
resource "databricks_catalog_workspace_binding" "this" {
107+
for_each = {
108+
for object in var.isolated_unmanaged_catalog_bindings : object.catalog_name => object
109+
}
110+
111+
workspace_id = var.workspace_id
112+
securable_name = each.value.catalog_name
113+
binding_type = each.value.binding_type
114+
}

variables.tf

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
variable "env" {
2-
type = string
3-
description = "Environment name"
4-
}
5-
61
variable "metastore_id" {
72
type = string
83
description = "Unity Catalog Metastore Id that is located in separate environment. Provide this value to associate Databricks Workspace with target Metastore"
@@ -19,22 +14,40 @@ variable "metastore_grants" {
1914
principal = string
2015
privileges = list(string)
2116
}))
22-
description = "Permissions to give on metastore to group"
17+
description = "Permissions to give on metastore to user, group or service principal"
2318
default = []
2419
}
2520

2621
variable "catalog" {
2722
type = map(object({
28-
catalog_grants = optional(map(list(string)))
29-
catalog_owner = optional(string)
30-
catalog_comment = optional(string)
31-
catalog_properties = optional(map(string))
32-
schema_name = optional(list(string))
33-
schema_grants = optional(map(list(string)))
34-
schema_owner = optional(string)
35-
schema_comment = optional(string)
36-
schema_properties = optional(map(string))
23+
catalog_grants = optional(map(list(string)))
24+
catalog_owner = optional(string) # Username/groupname/sp application_id of the catalog owner.
25+
catalog_storage_root = optional(string) # Location in cloud storage where data for managed tables will be stored
26+
catalog_isolation_mode = optional(string, "OPEN") # Whether the catalog is accessible from all workspaces or a specific set of workspaces. Can be ISOLATED or OPEN.
27+
catalog_comment = optional(string) # User-supplied free-form text
28+
catalog_properties = optional(map(string)) # Extensible Catalog Tags.
29+
schema_name = optional(list(string)) # List of Schema names relative to parent catalog.
30+
schema_grants = optional(map(list(string)))
31+
schema_owner = optional(string) # Username/groupname/sp application_id of the schema owner.
32+
schema_comment = optional(string)
33+
schema_properties = optional(map(string))
3734
}))
3835
description = "Map of catalog name and its parameters"
3936
default = {}
4037
}
38+
39+
variable "isolated_unmanaged_catalog_bindings" {
40+
type = list(object({
41+
catalog_name = string # Name of ISOLATED catalog
42+
binding_type = optional(string, "BINDING_TYPE_READ_WRITE") # Binding mode. Possible values are BINDING_TYPE_READ_ONLY, BINDING_TYPE_READ_WRITE
43+
}))
44+
description = "List of objects with parameters to configure Catalog Bindings"
45+
default = []
46+
}
47+
48+
variable "workspace_id" {
49+
type = string
50+
description = "ID of the target workspace."
51+
default = null
52+
}
53+

versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
databricks = {
66
source = "databricks/databricks"
7-
version = ">=1.14.2"
7+
version = ">=1.38.0"
88
}
99
}
1010
}

0 commit comments

Comments
 (0)