Skip to content

Commit f6974af

Browse files
MyroslavLevchykMyroslavLevchyk
authored andcommitted
upd
1 parent 636ce0d commit f6974af

File tree

4 files changed

+25
-34
lines changed

4 files changed

+25
-34
lines changed

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,8 @@ No modules.
214214
| <a name="input_iam_workspace_groups"></a> [iam\_workspace\_groups](#input\_iam\_workspace\_groups) | Used to create workspace group. Map of group name and its parameters, such as users and service principals added to the group. Also possible to configure group entitlements. | <pre>map(object({<br> user = optional(list(string))<br> service_principal = optional(list(string))<br> entitlements = optional(list(string))<br> }))</pre> | `{}` | no |
215215
| <a name="input_ip_addresses"></a> [ip\_addresses](#input\_ip\_addresses) | A map of IP address ranges | `map(string)` | <pre>{<br> "all": "0.0.0.0/0"<br>}</pre> | no |
216216
| <a name="input_key_vault_secret_scope"></a> [key\_vault\_secret\_scope](#input\_key\_vault\_secret\_scope) | Object with Azure Key Vault parameters required for creation of Azure-backed Databricks Secret scope | <pre>list(object({<br> name = string<br> key_vault_id = string<br> dns_name = string<br> tenant_id = string<br> }))</pre> | `[]` | no |
217-
| <a name="input_mount_cluster_name"></a> [mount\_cluster\_name](#input\_mount\_cluster\_name) | Name of the cluster that will be used during storage mounting. If mount\_adls\_passthrough == true, cluster should also have option cluster\_conf\_passthrought == true | `string` | `null` | no |
217+
| <a name="input_mount_configuration"></a> [mount\_configuration](#input\_mount\_configuration) | Configuration for mounting storage, including only service principal details | <pre>object({<br> service_principal = object({<br> client_id = string<br> client_secret = string<br> tenant_id = string<br> })<br> })</pre> | <pre>{<br> "service_principal": {<br> "client_id": null,<br> "client_secret": null,<br> "tenant_id": null<br> }<br>}</pre> | no |
218218
| <a name="input_mount_enabled"></a> [mount\_enabled](#input\_mount\_enabled) | Boolean flag that determines whether mount point for storage account filesystem is created | `bool` | `false` | no |
219-
| <a name="input_mount_service_principal_client_id"></a> [mount\_service\_principal\_client\_id](#input\_mount\_service\_principal\_client\_id) | Application(client) Id of Service Principal used to perform storage account mounting | `string` | `null` | no |
220-
| <a name="input_mount_service_principal_secret"></a> [mount\_service\_principal\_secret](#input\_mount\_service\_principal\_secret) | Service Principal Secret used to perform storage account mounting | `string` | `null` | no |
221-
| <a name="input_mount_service_principal_tenant_id"></a> [mount\_service\_principal\_tenant\_id](#input\_mount\_service\_principal\_tenant\_id) | Service Principal tenant id used to perform storage account mounting | `string` | `null` | no |
222219
| <a name="input_mountpoints"></a> [mountpoints](#input\_mountpoints) | Mountpoints for databricks | <pre>map(object({<br> storage_account_name = string<br> container_name = string<br> }))</pre> | `{}` | no |
223220
| <a name="input_pat_token_lifetime_seconds"></a> [pat\_token\_lifetime\_seconds](#input\_pat\_token\_lifetime\_seconds) | The lifetime of the token, in seconds. If no lifetime is specified, the token remains valid indefinitely | `number` | `315569520` | no |
224221
| <a name="input_secret_scope"></a> [secret\_scope](#input\_secret\_scope) | Provides an ability to create custom Secret Scope, store secrets in it and assigning ACL for access management<br>scope\_name - name of Secret Scope to create;<br>acl - list of objects, where 'principal' custom group name, this group is created in 'Premium' module; 'permission' is one of "READ", "WRITE", "MANAGE";<br>secrets - list of objects, where object's 'key' param is created key name and 'string\_value' is a value for it; | <pre>list(object({<br> scope_name = string<br> scope_acl = optional(list(object({<br> principal = string<br> permission = string<br> })))<br> secrets = optional(list(object({<br> key = string<br> string_value = string<br> })))<br> }))</pre> | `[]` | no |

mount.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
locals {
22
mount_sp_secrets = var.cloud_name == "azure" ? {
3-
mount-sp-client-id = { value = var.mount_service_principal_client_id }
4-
mount-sp-secret = { value = var.mount_service_principal_secret }
3+
mount_sp_client_id = { value = var.mount_configuration.service_principal.client_id }
4+
mount_sp_secret = { value = var.mount_configuration.service_principal.client_secret }
55
} : {}
66
}
77

88
resource "databricks_mount" "adls" {
9-
for_each = var.mount_enabled && var.cloud_name == "azure" ? var.mountpoints : {}
9+
for_each = var.mount_enabled && var.cloud_name == "azure" ? var.mount_configuration.mountpoints : {}
1010

1111
name = each.key
1212
uri = "abfss://${each.value["container_name"]}@${each.value["storage_account_name"]}.dfs.core.windows.net"
1313
extra_configs = {
1414
"fs.azure.account.auth.type" : "OAuth",
1515
"fs.azure.account.oauth.provider.type" : "org.apache.hadoop.fs.azurebfs.oauth2.ClientCredsTokenProvider",
16-
"fs.azure.account.oauth2.client.id" : var.mount_service_principal_client_id,
16+
"fs.azure.account.oauth2.client.id" : var.mount_configuration.service_principal.client_id,
1717
"fs.azure.account.oauth2.client.secret" : databricks_secret.main["mount-sp-secret"].config_reference,
18-
"fs.azure.account.oauth2.client.endpoint" : "https://login.microsoftonline.com/${var.mount_service_principal_tenant_id}/oauth2/token",
18+
"fs.azure.account.oauth2.client.endpoint" : "https://login.microsoftonline.com/${var.mount_configuration.service_principal.tenant_id}/oauth2/token",
1919
"fs.azure.createRemoteFileSystemDuringInitialization" : "false",
2020
}
2121
}

secrets.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ resource "databricks_secret" "main" {
3131

3232
lifecycle {
3333
precondition {
34-
condition = var.cloud_name == "azure" && var.mount_enabled ? length(compact([var.mount_service_principal_client_id, var.mount_service_principal_secret, var.mount_service_principal_tenant_id])) == 3 : true
35-
error_message = "To mount ADLS Storage, please provide prerequisite Service Principal values - 'mount_service_principal_object_id', 'mount_service_principal_secret', 'mount_service_principal_tenant_id'."
34+
condition = var.cloud_name == "azure" && var.mount_enabled ? length(compact([var.mount_configuration.service_principal.client_id, var.mount_configuration.service_principal.client_secret, var.mount_configuration.service_principal.tenant_id])) == 3 : true
35+
error_message = "To mount ADLS Storage, please provide prerequisite Service Principal values - 'mount_configuration.service_principal.client_id', 'mount_configuration.service_principal.client_secret', 'mount_configuration.service_principal.tenant_id'."
3636
}
3737
}
3838
}

variables.tf

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -187,23 +187,23 @@ variable "mount_enabled" {
187187
default = false
188188
}
189189

190-
variable "mount_service_principal_client_id" {
191-
type = string
192-
description = "Application(client) Id of Service Principal used to perform storage account mounting"
193-
default = null
194-
}
195-
196-
variable "mount_service_principal_secret" {
197-
type = string
198-
description = "Service Principal Secret used to perform storage account mounting"
199-
default = null
200-
sensitive = true
201-
}
202-
203-
variable "mount_service_principal_tenant_id" {
204-
type = string
205-
description = "Service Principal tenant id used to perform storage account mounting"
206-
default = null
190+
variable "mount_configuration" {
191+
type = object({
192+
service_principal = object({
193+
client_id = string
194+
client_secret = string
195+
tenant_id = string
196+
})
197+
})
198+
description = "Configuration for mounting storage, including only service principal details"
199+
default = {
200+
service_principal = {
201+
client_id = null
202+
client_secret = null
203+
tenant_id = null
204+
}
205+
}
206+
sensitive = true
207207
}
208208

209209
variable "mountpoints" {
@@ -215,12 +215,6 @@ variable "mountpoints" {
215215
default = {}
216216
}
217217

218-
variable "mount_cluster_name" {
219-
type = string
220-
description = "Name of the cluster that will be used during storage mounting. If mount_adls_passthrough == true, cluster should also have option cluster_conf_passthrought == true"
221-
default = null
222-
}
223-
224218
variable "system_schemas" {
225219
type = set(string)
226220
description = "Set of strings with all possible System Schema names"

0 commit comments

Comments
 (0)