Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove non-applicable permission from dbx volume grant and add all privileges group #684

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion databricks-s3-volume/grants.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
locals {
# Only set the grant principals if the catalog and/or schema doesn't already exist
catalog_all_priv_grant_principals = var.create_catalog ? var.catalog_all_priv_grant_principals : []
catalog_all_priv_grant_principals = concat(local.catalog_all_priv_grant_principals, [var.owner])
catalog_r_grant_principals = var.create_catalog ? var.catalog_r_grant_principals : []
catalog_rw_grant_principals = var.create_catalog ? var.catalog_rw_grant_principals : []
schema_r_grant_principals = var.create_schema ? var.schema_r_grant_principals : []
schema_rw_grant_principals = var.create_schema ? var.schema_rw_grant_principals : []
}

# catalog

resource "databricks_grant" "catalog_all_privileges" {
depends_on = [databricks_catalog.volume[0]]
for_each = toset(local.catalog_all_priv_grant_principals)

catalog = local.catalog_name
principal = each.value
privileges = ["ALL_PRIVILEGES"]
}

resource "databricks_grant" "catalog_r" {
depends_on = [databricks_catalog.volume[0]]
for_each = toset(local.catalog_r_grant_principals)
Expand Down Expand Up @@ -64,7 +76,7 @@ resource "databricks_grant" "volume_r" {
for_each = toset(var.volume_r_grant_principals)
volume = databricks_volume.volume.id
principal = each.value
privileges = ["READ_VOLUME", "READ_FILES"]
privileges = ["READ_VOLUME"]
}

resource "databricks_grant" "volume_rw" {
Expand Down
6 changes: 6 additions & 0 deletions databricks-s3-volume/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ variable "bucket_object_ownership" {
}
}

variable "catalog_all_priv_grant_principals" {
description = "(Optional) Databricks groups to grant all-privileges permission to on the catalog. Owner is included"
type = list(string)
default = []
}

variable "catalog_r_grant_principals" {
description = "(Optional) Databricks groups to grant read-only permissions to on the catalog"
type = list(string)
Expand Down
Loading