Skip to content

Commit 08e64a1

Browse files
committed
fix: added condition for key vault access policy creation
1 parent 1cbc754 commit 08e64a1

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

secrets.tf

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,27 @@ resource "databricks_secret" "this" {
4646

4747
# Azure Key Vault-backed Scope
4848
resource "azurerm_key_vault_access_policy" "databricks" {
49-
for_each = {
49+
for_each = var.create_databricks_access_policy_to_key_vault ? {
5050
for param in var.key_vault_secret_scope : (param.name) => param
5151
if length(param.name) != 0
52-
}
52+
} : {}
53+
54+
key_vault_id = each.value.key_vault_id
55+
object_id = "9b38785a-6e08-4087-a0c4-20634343f21f" # Global 'AzureDatabricks' SP object id
56+
tenant_id = data.azurerm_key_vault_secret.tenant_id.value
57+
58+
secret_permissions = [
59+
"Get",
60+
"List",
61+
]
62+
}
63+
64+
# Azure Key Vault-backed Scope
65+
resource "azurerm_key_vault_access_policy" "databricks" {
66+
for_each = var.create_databricks_access_policy_to_key_vault ? {
67+
for param in var.key_vault_secret_scope : (param.name) => param
68+
if length(param.name) != 0
69+
} : {}
5370

5471
key_vault_id = each.value.key_vault_id
5572
object_id = "9b38785a-6e08-4087-a0c4-20634343f21f" # Global 'AzureDatabricks' SP object id

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ variable "key_vault_id" {
118118
}
119119

120120
# Azure Key Vault-backed Secret Scope
121+
variable "create_databricks_access_policy_to_key_vault" {
122+
type = bool
123+
description = "Boolean flag to enable creation of Key Vault Access Policy for Databricks Global Service Principal."
124+
default = true
125+
}
126+
121127
variable "key_vault_secret_scope" {
122128
type = list(object({
123129
name = optional(string)

0 commit comments

Comments
 (0)