Skip to content

Commit 5d225f5

Browse files
authored
feat: add use / manage privilege groups. expose external location and catalogs as output (#755)
* Add use group. Expose external location and catalogs as output * add manage group
1 parent 3543048 commit 5d225f5

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

databricks-catalog-external-location/catalogs.tf

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ resource "databricks_grants" "grants" {
1818
databricks_catalog.catalog
1919
]
2020

21+
dynamic "grant" {
22+
for_each = toset(each.value.manage_privileges_groups)
23+
content {
24+
principal = grant.value
25+
privileges = [
26+
"ALL_PRIVILEGES",
27+
"MANAGE",
28+
]
29+
}
30+
}
31+
2132
dynamic "grant" {
2233
for_each = toset(each.value.all_privileges_groups)
2334
content {
@@ -29,31 +40,41 @@ resource "databricks_grants" "grants" {
2940
}
3041

3142
dynamic "grant" {
32-
for_each = toset(each.value.read_privileges_groups)
43+
for_each = toset(each.value.write_privileges_groups)
3344
content {
3445
principal = grant.value
3546
privileges = [
3647
"USE_CATALOG",
3748
"USE_SCHEMA",
3849
"SELECT",
50+
"CREATE_TABLE",
51+
"CREATE_SCHEMA",
52+
"MODIFY",
3953
"BROWSE",
4054
]
4155
}
4256
}
4357

4458
dynamic "grant" {
45-
for_each = toset(each.value.write_privileges_groups)
59+
for_each = toset(each.value.read_privileges_groups)
4660
content {
4761
principal = grant.value
4862
privileges = [
4963
"USE_CATALOG",
5064
"USE_SCHEMA",
5165
"SELECT",
52-
"CREATE_TABLE",
53-
"CREATE_SCHEMA",
54-
"MODIFY",
5566
"BROWSE",
5667
]
5768
}
5869
}
70+
71+
dynamic "grant" {
72+
for_each = toset(each.value.use_privileges_groups)
73+
content {
74+
principal = grant.value
75+
privileges = [
76+
"USE_CATALOG",
77+
]
78+
}
79+
}
5980
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
output "catalogs" {
2+
description = "Map of created Databricks catalogs, keyed by catalog name"
3+
value = databricks_catalog.catalog
4+
}
5+
6+
output "external_location" {
7+
description = "The Databricks external location"
8+
value = databricks_external_location.external_locations
9+
}

databricks-catalog-external-location/variables.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ variable "catalogs" {
4545
enable_predictive_optimization = optional(string, "INHERIT")
4646
owner = string
4747
all_privileges_groups = list(string)
48+
manage_privileges_groups = optional(list(string), [])
4849
read_privileges_groups = optional(list(string), [])
4950
write_privileges_groups = optional(list(string), [])
51+
use_privileges_groups = optional(list(string), [])
5052
catalog_prefix = optional(string, "")
5153
}))
5254
}

0 commit comments

Comments
 (0)