|
| 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 | + |
1 | 14 | resource "databricks_cluster" "cluster" {
|
2 | 15 | for_each = { for cluster in var.clusters : cluster.cluster_name => cluster }
|
3 | 16 |
|
4 | 17 | cluster_name = each.value.cluster_name
|
5 | 18 | 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) |
12 | 23 | spark_env_vars = each.value.spark_env_vars
|
13 | 24 | data_security_mode = each.value.cluster_conf_passthrought ? null : each.value.data_security_mode
|
14 | 25 | node_type_id = each.value.node_type_id
|
15 | 26 | autotermination_minutes = each.value.autotermination_minutes
|
16 | 27 | single_user_name = each.value.single_user_name
|
| 28 | + custom_tags = each.value.single_node_enable ? each.value.custom_tags : null |
17 | 29 |
|
18 |
| - autoscale { |
19 |
| - min_workers = each.value.min_workers |
20 |
| - max_workers = each.value.max_workers |
| 30 | + dynamic "azure_attributes" { |
| 31 | + for_each = each.value.single_node_enable == true ? [] : [1] |
| 32 | + content { |
| 33 | + availability = each.value.availability |
| 34 | + first_on_demand = each.value.first_on_demand |
| 35 | + spot_bid_max_price = each.value.spot_bid_max_price |
| 36 | + } |
21 | 37 | }
|
22 | 38 |
|
23 |
| - azure_attributes { |
24 |
| - availability = each.value.availability |
25 |
| - first_on_demand = each.value.first_on_demand |
26 |
| - spot_bid_max_price = each.value.spot_bid_max_price |
| 39 | + dynamic "autoscale" { |
| 40 | + for_each = each.value.single_node_enable == true ? [] : [1] |
| 41 | + content { |
| 42 | + min_workers = each.value.min_workers |
| 43 | + max_workers = each.value.max_workers |
| 44 | + } |
27 | 45 | }
|
28 | 46 |
|
29 | 47 | dynamic "cluster_log_conf" {
|
|
0 commit comments