-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.tf
52 lines (41 loc) · 1.48 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
locals {
ip_rules = var.ip_rules == null ? null : values(var.ip_rules)
suffix = length(var.suffix) == 0 ? "" : "-${var.suffix}"
}
resource "databricks_workspace_conf" "this" {
count = local.ip_rules == null ? 0 : 1
custom_config = {
"enableIpAccessLists" : true
}
}
resource "databricks_token" "pat" {
comment = "Terraform Provisioning"
lifetime_seconds = var.pat_token_lifetime_seconds
}
resource "databricks_ip_access_list" "this" {
count = local.ip_rules == null ? 0 : 1
label = "allow_in"
list_type = "ALLOW"
ip_addresses = local.ip_rules
depends_on = [databricks_workspace_conf.this]
}
# SQL Endpoint
resource "databricks_sql_endpoint" "this" {
for_each = { for endpoint in var.sql_endpoint : (endpoint.name) => endpoint }
name = "${each.key}${local.suffix}"
cluster_size = each.value.cluster_size
min_num_clusters = each.value.min_num_clusters
max_num_clusters = each.value.max_num_clusters
auto_stop_mins = each.value.auto_stop_mins
enable_photon = each.value.enable_photon
enable_serverless_compute = each.value.enable_serverless_compute
spot_instance_policy = each.value.spot_instance_policy
warehouse_type = each.value.warehouse_type
lifecycle {
ignore_changes = [state, num_clusters]
}
}
resource "databricks_system_schema" "this" {
for_each = var.system_schemas_enabled ? var.system_schemas : toset([])
schema = each.value
}