Skip to content

Commit 015894c

Browse files
authored
prevent unintentional user deactivation or deletion (#91)
Prevent the destruction of databricks users by terraform and add a link to azure documentation in the comments
1 parent 9acefbf commit 015894c

File tree

1 file changed

+15
-8
lines changed
  • examples/adb-unity-catalog-basic-demo/modules/metastore-and-users

1 file changed

+15
-8
lines changed

examples/adb-unity-catalog-basic-demo/modules/metastore-and-users/main.tf

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,20 @@ locals {
142142

143143
// All governed by AzureAD, create or remove users to/from databricks account
144144
resource "databricks_user" "this" {
145-
provider = databricks.azure_account
146-
for_each = local.all_users
147-
user_name = lower(local.all_users[each.key]["user_principal_name"])
148-
display_name = local.all_users[each.key]["display_name"]
149-
active = local.all_users[each.key]["account_enabled"]
150-
external_id = each.key
151-
force = true
145+
provider = databricks.azure_account
146+
for_each = local.all_users
147+
user_name = lower(local.all_users[each.key]["user_principal_name"])
148+
display_name = local.all_users[each.key]["display_name"]
149+
active = local.all_users[each.key]["account_enabled"]
150+
external_id = each.key
151+
force = true
152+
disable_as_user_deletion = true # default behavior
153+
154+
// Review warning before deactivating or deleting users from databricks account
155+
// https://learn.microsoft.com/en-us/azure/databricks/administration-guide/users-groups/scim/#add-users-and-groups-to-your-azure-databricks-account-using-azure-active-directory-azure-ad
156+
lifecycle {
157+
prevent_destroy = true
158+
}
152159
}
153160

154161
// Extract information about service prinicpals users
@@ -195,4 +202,4 @@ resource "databricks_user_role" "account_admin" {
195202
user_id = databricks_user.this[each.key].id
196203
role = "account_admin"
197204
depends_on = [databricks_group.this, databricks_user.this, databricks_service_principal.sp]
198-
}
205+
}

0 commit comments

Comments
 (0)