Skip to content

Commit c2361a6

Browse files
authored
Merge pull request #45 from data-platform-hq/cluster-support-single-node
feat: support single node clusters
2 parents 95ec206 + 2936d1d commit c2361a6

File tree

4 files changed

+32
-15
lines changed

4 files changed

+32
-15
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,14 @@ module "metastore_assignment" {
164164
|------|---------|
165165
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >=1.0.0 |
166166
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | >=3.40.0 |
167-
| <a name="requirement_databricks"></a> [databricks](#requirement\_databricks) | >=1.14.2 |
167+
| <a name="requirement_databricks"></a> [databricks](#requirement\_databricks) | >=1.30.0 |
168168

169169
## Providers
170170

171171
| Name | Version |
172172
|------|---------|
173173
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | >=3.40.0 |
174-
| <a name="provider_databricks"></a> [databricks](#provider\_databricks) | >=1.14.2 |
174+
| <a name="provider_databricks"></a> [databricks](#provider\_databricks) | >=1.30.0 |
175175

176176
## Modules
177177

@@ -213,7 +213,7 @@ No modules.
213213

214214
| Name | Description | Type | Default | Required |
215215
|------|-------------|------|---------|:--------:|
216-
| <a name="input_clusters"></a> [clusters](#input\_clusters) | Set of objects with parameters to configure Databricks clusters and assign permissions to it for certain custom groups | <pre>set(object({<br> cluster_name = string<br> spark_version = optional(string, "13.3.x-scala2.12")<br> spark_conf = optional(map(any), {})<br> cluster_conf_passthrought = optional(bool, false)<br> spark_env_vars = optional(map(any), {})<br> data_security_mode = optional(string, "USER_ISOLATION")<br> node_type_id = optional(string, "Standard_D3_v2")<br> autotermination_minutes = optional(number, 30)<br> min_workers = optional(number, 1)<br> max_workers = optional(number, 2)<br> availability = optional(string, "ON_DEMAND_AZURE")<br> first_on_demand = optional(number, 0)<br> spot_bid_max_price = optional(number, 1)<br> cluster_log_conf_destination = optional(string, null)<br> init_scripts_workspace = optional(set(string), [])<br> init_scripts_volumes = optional(set(string), [])<br> init_scripts_dbfs = optional(set(string), [])<br> init_scripts_abfss = optional(set(string), [])<br> single_user_name = optional(string, null)<br> permissions = optional(set(object({<br> group_name = string<br> permission_level = string<br> })), [])<br> pypi_library_repository = optional(set(string), [])<br> maven_library_repository = optional(set(object({<br> coordinates = string<br> exclusions = set(string)<br> })), [])<br> }))</pre> | `[]` | no |
216+
| <a name="input_clusters"></a> [clusters](#input\_clusters) | Set of objects with parameters to configure Databricks clusters and assign permissions to it for certain custom groups | <pre>set(object({<br> cluster_name = string<br> spark_version = optional(string, "13.3.x-scala2.12")<br> spark_conf = optional(map(any), {})<br> cluster_conf_passthrought = optional(bool, false)<br> spark_env_vars = optional(map(any), {})<br> data_security_mode = optional(string, "USER_ISOLATION")<br> node_type_id = optional(string, "Standard_D3_v2")<br> autotermination_minutes = optional(number, 30)<br> min_workers = optional(number, 1)<br> max_workers = optional(number, 2)<br> availability = optional(string, "ON_DEMAND_AZURE")<br> first_on_demand = optional(number, 0)<br> spot_bid_max_price = optional(number, 1)<br> cluster_log_conf_destination = optional(string, null)<br> init_scripts_workspace = optional(set(string), [])<br> init_scripts_volumes = optional(set(string), [])<br> init_scripts_dbfs = optional(set(string), [])<br> init_scripts_abfss = optional(set(string), [])<br> single_user_name = optional(string, null)<br> single_node_enable = optional(bool, false)<br> custom_tags = optional(map(string), {})<br> permissions = optional(set(object({<br> group_name = string<br> permission_level = string<br> })), [])<br> pypi_library_repository = optional(set(string), [])<br> maven_library_repository = optional(set(object({<br> coordinates = string<br> exclusions = set(string)<br> })), [])<br> }))</pre> | `[]` | no |
217217
| <a name="input_create_databricks_access_policy_to_key_vault"></a> [create\_databricks\_access\_policy\_to\_key\_vault](#input\_create\_databricks\_access\_policy\_to\_key\_vault) | Boolean flag to enable creation of Key Vault Access Policy for Databricks Global Service Principal. | `bool` | `true` | no |
218218
| <a name="input_custom_cluster_policies"></a> [custom\_cluster\_policies](#input\_custom\_cluster\_policies) | Provides an ability to create custom cluster policy, assign it to cluster and grant CAN\_USE permissions on it to certain custom groups<br>name - name of custom cluster policy to create<br>can\_use - list of string, where values are custom group names, there groups have to be created with Terraform;<br>definition - JSON document expressed in Databricks Policy Definition Language. No need to call 'jsonencode()' function on it when providing a value; | <pre>list(object({<br> name = string<br> can_use = list(string)<br> definition = any<br> }))</pre> | <pre>[<br> {<br> "can_use": null,<br> "definition": null,<br> "name": null<br> }<br>]</pre> | no |
219219
| <a name="input_global_databricks_sp_object_id"></a> [global\_databricks\_sp\_object\_id](#input\_global\_databricks\_sp\_object\_id) | Global 'AzureDatabricks' SP object id. Used to create Key Vault Access Policy for Secret Scope | `string` | `"9b38785a-6e08-4087-a0c4-20634343f21f"` | no |

cluster.tf

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,46 @@
1+
locals {
2+
spark_conf_single_node = {
3+
"spark.master" = "local[*]"
4+
"spark.databricks.cluster.profile" = "singleNode"
5+
}
6+
conf_passthrought = {
7+
"spark.databricks.cluster.profile" : "serverless",
8+
"spark.databricks.repl.allowedLanguages" : "python,sql",
9+
"spark.databricks.passthrough.enabled" : "true",
10+
"spark.databricks.pyspark.enableProcessIsolation" : "true"
11+
}
12+
}
13+
114
resource "databricks_cluster" "cluster" {
215
for_each = { for cluster in var.clusters : cluster.cluster_name => cluster }
316

417
cluster_name = each.value.cluster_name
518
spark_version = each.value.spark_version
6-
spark_conf = each.value.cluster_conf_passthrought ? merge({
7-
"spark.databricks.cluster.profile" : "serverless",
8-
"spark.databricks.repl.allowedLanguages" : "python,sql",
9-
"spark.databricks.passthrough.enabled" : "true",
10-
"spark.databricks.pyspark.enableProcessIsolation" : "true"
11-
}, each.value.spark_conf) : each.value.spark_conf
19+
spark_conf = merge(
20+
each.value.cluster_conf_passthrought ? local.conf_passthrought : {},
21+
each.value.single_node_enable == true ? local.spark_conf_single_node : {},
22+
each.value.spark_conf)
1223
spark_env_vars = each.value.spark_env_vars
1324
data_security_mode = each.value.cluster_conf_passthrought ? null : each.value.data_security_mode
1425
node_type_id = each.value.node_type_id
1526
autotermination_minutes = each.value.autotermination_minutes
1627
single_user_name = each.value.single_user_name
17-
18-
autoscale {
19-
min_workers = each.value.min_workers
20-
max_workers = each.value.max_workers
21-
}
28+
custom_tags = merge(each.value.single_node_enable ? { "ResourceClass" = "SingleNode" } : {}, each.value.custom_tags)
2229

2330
azure_attributes {
2431
availability = each.value.availability
2532
first_on_demand = each.value.first_on_demand
2633
spot_bid_max_price = each.value.spot_bid_max_price
2734
}
2835

36+
dynamic "autoscale" {
37+
for_each = each.value.single_node_enable ? [] : [1]
38+
content {
39+
min_workers = each.value.min_workers
40+
max_workers = each.value.max_workers
41+
}
42+
}
43+
2944
dynamic "cluster_log_conf" {
3045
for_each = each.value.cluster_log_conf_destination != null ? [each.value.cluster_log_conf_destination] : []
3146
content {

variables.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ variable "clusters" {
166166
init_scripts_dbfs = optional(set(string), [])
167167
init_scripts_abfss = optional(set(string), [])
168168
single_user_name = optional(string, null)
169+
single_node_enable = optional(bool, false)
170+
custom_tags = optional(map(string), {})
169171
permissions = optional(set(object({
170172
group_name = string
171173
permission_level = string

versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ terraform {
88
}
99
databricks = {
1010
source = "databricks/databricks"
11-
version = ">=1.14.2"
11+
version = ">=1.30.0"
1212
}
1313
}
1414
}

0 commit comments

Comments
 (0)