@@ -17,21 +17,49 @@ provider "databricks" {
1717}
1818
1919locals {
20- metastore_id = "10000000-0000-0000-0000-0000000000"
21-
22- metastore_grants = [
23- { principal = "<[email protected] >", privileges = ["CREATE_CATALOG","CREATE_EXTERNAL_LOCATION"] }, 24- { principal = "<[email protected] >", privileges = ["CREATE_SHARE", "CREATE_RECIPIENT", "CREATE_PROVIDER"] } 20+ catalog_config = [
21+
22+ # Catalog w/o grants
23+ {
24+ catalog_name = "catalog_with_no_grants"
25+ },
26+
27+ # Catalog with grants
28+ {
29+ catalog_name = "catalog_with_grants"
30+ catalog_grants = [
31+ { principal = "account users", privileges = ["USE_CATALOG", "APPLY_TAG", "CREATE_SCHEMA", "SELECT"] }
32+ ]
33+ },
34+
35+ # Catalog with grants and schemas
36+ {
37+ catalog_name = "catalog_with_schemas"
38+ catalog_grants = [{ principal = "account users", privileges = ["USE_CATALOG", "APPLY_TAG", "SELECT"] }]
39+ schema_configs = [
40+ { schema_name = "schema_01" },
41+ { schema_name = "schema_02" }
42+ ]
43+ },
44+
45+ # Catalog with schemas where 'schema_01' and 'schema_02' have a default set of grants from 'schema_default_grants' parameter
46+ # and 'schema_03' has its own set of grants managed with 'schema_custom_grants' parameter
47+ {
48+ catalog_name = "catalog_custom_schema_grants"
49+ catalog_grants = [{ principal = "account users", privileges = ["USE_CATALOG", "APPLY_TAG"] }]
50+ schema_default_grants = [{ principal = "account users", privileges = ["CREATE_TABLE", "SELECT"] }]
51+ schema_configs = [
52+ { schema_name = "schema_01" },
53+ { schema_name = "schema_02" },
54+ {
55+ schema_name = "schema_03",
56+ schema_custom_grants = [
57+ { principal = "account users", privileges = ["CREATE_VOLUME", "READ_VOLUME", "WRITE_VOLUME", "SELECT"] },
58+ ]
59+ },
60+ ]
61+ },
2562 ]
26-
27- catalog = {
28- example_catalog = {
29- catalog_grants = {
30- "[email protected] " = ["USE_CATALOG", "USE_SCHEMA", "CREATE_SCHEMA", "CREATE_TABLE", "SELECT", "MODIFY"] 31- }
32- schema_name = ["raw", "refined", "data_product"]
33- }
34- }
3563}
3664
3765# Prerequisite module.
@@ -50,12 +78,9 @@ module "metastore_assignment" {
5078
5179module "unity_catalog" {
5280 source = "data-platform/unity-catalog/databricks"
53- version = "~> 1.1 .0"
81+ version = "~> 2.0 .0"
5482
55- env = "example"
56- metastore_id = local.metastore_id
57- metastore_grants = local.metastore_grants
58- catalog = local.catalog
83+ catalog_config = local.catalog_config
5984
6085 providers = {
6186 databricks = databricks.workspace
0 commit comments