Skip to content

Commit f28fd5c

Browse files
authored
Merge pull request #71 from tomarv2/develop
Pulling refs/heads/develop into main
2 parents d526d14 + eda41d1 commit f28fd5c

File tree

5 files changed

+42
-15
lines changed

5 files changed

+42
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
## Versions
2727

2828
- Module tested for Terraform 1.0.1.
29-
- `databricks/databricks` provider version [0.5.7](https://registry.terraform.io/providers/databricks/databricks/latest)
29+
- `databricks/databricks` provider version [1.3.0](https://registry.terraform.io/providers/databricks/databricks/latest)
3030
- AWS provider version [4.14](https://registry.terraform.io/providers/hashicorp/aws/latest).
3131
- `main` branch: Provider versions not pinned to keep up with Terraform releases.
3232
- `tags` releases: Tags are pinned with versions (use <a href="https://github.com/tomarv2/terraform-databricks-workspace-management/tags" alt="GitHub tag">

examples/jobs/4_job_on_existing_cluster_with_new_notebooks/main.tf

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,36 @@ terraform {
1212
}
1313
}
1414

15+
module "cluster" {
16+
source = "../../../"
17+
# ------------------------------------------------
18+
# CLUSTER
19+
# ------------------------------------------------
20+
deploy_cluster = true
21+
fixed_value = 0
22+
23+
# libraries = {
24+
# maven = {
25+
# "com.microsoft.azure:azure-eventhubs-spark_2.12:2.3.21" = {}
26+
# }
27+
# python_wheel = {}
28+
# }
1529

16-
module "databricks_workspace_management" {
30+
# ------------------------------------------------
31+
# Do not change the teamid, prjid once set.
32+
teamid = var.teamid
33+
prjid = var.prjid
34+
}
35+
36+
module "jobs" {
1737
source = "../../../"
1838

1939
# ------------------------------------------------
2040
# JOB
2141
# ------------------------------------------------
2242
deploy_jobs = true
23-
cluster_id = "0907-052446-bike152"
24-
fixed_value = 1
43+
cluster_id = module.cluster.cluster_id
44+
#fixed_value = 1
2545
retry_on_timeout = false
2646
max_retries = 3
2747
timeout = 30
@@ -57,6 +77,13 @@ module "databricks_workspace_management" {
5777
local_path = "notebooks/sample2.py"
5878
}
5979
]
80+
jobs_access_control = [
81+
{
82+
group_name = "demo"
83+
permission_level = "CAN_MANAGE_RUN"
84+
}
85+
]
86+
depends_on = [module.cluster]
6087
# ------------------------------------------------
6188
# Do not change the teamid, prjid once set.
6289
teamid = var.teamid
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
output "notebook_url" {
22
description = "databricks notebook url"
3-
value = module.databricks_workspace_management.notebook_url
3+
value = module.jobs.notebook_url
44
}
55

66
output "job_url" {
77
description = "databricks job url"
8-
value = module.databricks_workspace_management.existing_cluster_new_job_new_notebooks_job
8+
value = module.jobs.existing_cluster_new_job_new_notebooks_job
99
}
1010

1111
output "job_id" {
1212
description = "databricks job id"
13-
value = module.databricks_workspace_management.existing_cluster_new_job_new_notebooks_id
13+
value = module.jobs.existing_cluster_new_job_new_notebooks_id
1414
}
1515

job.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# 1. NEW CLUSTER WITH NEW NOTEBOOKS
44
# ------------------------------------------------
55
resource "databricks_job" "new_cluster_new_job_new_notebooks" {
6-
for_each = (var.deploy_jobs == true && var.cluster_id == null && var.deploy_cluster == true && var.local_notebooks != null) ? { for p in var.local_notebooks : "${p.job_name}-${p.local_path}" => p } : {}
6+
for_each = (var.deploy_jobs == true && var.deploy_cluster == true && var.local_notebooks != null) ? { for p in var.local_notebooks : "${p.job_name}-${p.local_path}" => p } : {}
77

88
name = "${each.value.job_name} (Terraform managed)"
99

@@ -93,7 +93,7 @@ resource "databricks_job" "new_cluster_new_job_new_notebooks" {
9393
# 2. NEW CLUSTER WITH EXITING NOTEBOOKS
9494
# ------------------------------------------------
9595
resource "databricks_job" "new_cluster_new_job_existing_notebooks" {
96-
for_each = (var.deploy_jobs == true && var.cluster_id == null && var.deploy_cluster == true && var.remote_notebooks != null) ? { for p in var.remote_notebooks : "${p.job_name}-${p.path}" => p } : {}
96+
for_each = (var.deploy_jobs == true && var.deploy_cluster == true && var.remote_notebooks != null) ? { for p in var.remote_notebooks : "${p.job_name}-${p.path}" => p } : {}
9797

9898
name = "${each.value.job_name} (Terraform managed)"
9999

@@ -184,7 +184,7 @@ resource "databricks_job" "new_cluster_new_job_existing_notebooks" {
184184
# 3. EXISTING CLUSTER WITH NEW NOTEBOOKS
185185
# ------------------------------------------------
186186
resource "databricks_job" "existing_cluster_new_job_new_notebooks" {
187-
for_each = (var.deploy_jobs == true && (var.cluster_id != null || var.deploy_cluster == false) && var.local_notebooks != null) ? { for p in var.local_notebooks : "${p.job_name}-${p.local_path}" => p } : {}
187+
for_each = (var.deploy_jobs == true && (var.deploy_cluster == false) && var.local_notebooks != null) ? { for p in var.local_notebooks : "${p.job_name}-${p.local_path}" => p } : {}
188188

189189
name = "${each.value.job_name} (Terraform managed)"
190190
existing_cluster_id = local.cluster_info
@@ -224,7 +224,7 @@ resource "databricks_job" "existing_cluster_new_job_new_notebooks" {
224224
# 4. EXISTING CLUSTER WITH EXITING NOTEBOOKS
225225
# ------------------------------------------------
226226
resource "databricks_job" "existing_cluster_new_job_existing_notebooks" {
227-
for_each = var.deploy_jobs == true && (var.cluster_id != null || var.deploy_cluster == false) && var.remote_notebooks != null ? { for p in var.remote_notebooks : "${p.job_name}-${p.path}" => p } : {}
227+
for_each = var.deploy_jobs == true && (var.deploy_cluster == false) && var.remote_notebooks != null ? { for p in var.remote_notebooks : "${p.job_name}-${p.path}" => p } : {}
228228

229229
name = "${each.value.job_name} (Terraform managed)"
230230
existing_cluster_id = local.cluster_info

permissions.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ resource "databricks_permissions" "policy" {
7272
# 1. NEW CLUSTER WITH NEW NOTEBOOKS
7373
# ------------------------------------------------
7474
resource "databricks_permissions" "new_cluster_new_job_new_notebooks" {
75-
for_each = (var.jobs_access_control != null && var.deploy_jobs == true && var.cluster_id == null && var.local_notebooks != null) ? databricks_job.new_cluster_new_job_new_notebooks : {}
75+
for_each = (var.jobs_access_control != null && var.deploy_jobs == true && var.local_notebooks != null) ? databricks_job.new_cluster_new_job_new_notebooks : {}
7676

7777
job_id = each.value.id
7878

@@ -89,7 +89,7 @@ resource "databricks_permissions" "new_cluster_new_job_new_notebooks" {
8989
# 2. EXISTING CLUSTER WITH NEW NOTEBOOKS
9090
# ------------------------------------------------
9191
resource "databricks_permissions" "existing_cluster_new_job_new_notebooks" {
92-
for_each = (var.jobs_access_control != null && var.deploy_jobs == true && var.cluster_id != null && var.local_notebooks != null) ? databricks_job.existing_cluster_new_job_new_notebooks : {}
92+
for_each = (var.jobs_access_control != null && var.deploy_jobs == true && var.local_notebooks != null) ? databricks_job.existing_cluster_new_job_new_notebooks : {}
9393

9494
job_id = each.value.id
9595

@@ -106,7 +106,7 @@ resource "databricks_permissions" "existing_cluster_new_job_new_notebooks" {
106106
# 3. NEW CLUSTER WITH EXITING NOTEBOOKS
107107
# ------------------------------------------------
108108
resource "databricks_permissions" "new_cluster_new_job_existing_notebooks" {
109-
for_each = (var.jobs_access_control != null && var.deploy_jobs == true && var.cluster_id == null && var.remote_notebooks != null) ? databricks_job.new_cluster_new_job_existing_notebooks : {}
109+
for_each = (var.jobs_access_control != null && var.deploy_jobs == true && var.remote_notebooks != null) ? databricks_job.new_cluster_new_job_existing_notebooks : {}
110110

111111
job_id = each.value.id
112112

@@ -123,7 +123,7 @@ resource "databricks_permissions" "new_cluster_new_job_existing_notebooks" {
123123
# 4. EXISTING CLUSTER WITH EXITING NOTEBOOKS
124124
# ------------------------------------------------
125125
resource "databricks_permissions" "existing_cluster_new_job_existing_notebooks" {
126-
for_each = (var.jobs_access_control != null && var.deploy_jobs == true && var.cluster_id != null && var.remote_notebooks != null) ? databricks_job.existing_cluster_new_job_existing_notebooks : {}
126+
for_each = (var.jobs_access_control != null && var.deploy_jobs == true && var.remote_notebooks != null) ? databricks_job.existing_cluster_new_job_existing_notebooks : {}
127127

128128
job_id = each.value.id
129129

0 commit comments

Comments
 (0)