Skip to content

Commit

Permalink
Exporter: skip listing of jobs deployed with DABs
Browse files Browse the repository at this point in the history
Because these jobs could be deployed with DABs it makes little sense to export them into Terraform...
  • Loading branch information
alexott committed Apr 9, 2024
1 parent c7d6292 commit 0110db5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/guides/experimental-exporter.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Services are just logical groups of resources used for filtering and organizatio
* `directories` - **listing** [databricks_directory](../resources/directory.md).
* `dlt` - **listing** [databricks_pipeline](../resources/pipeline.md).
* `groups` - **listing** [databricks_group](../data-sources/group.md) with [membership](../resources/group_member.md) and [data access](../resources/group_instance_profile.md).
* `jobs` - **listing** [databricks_job](../resources/job.md). Usually, there are more automated jobs than interactive clusters, so they get their own file in this tool's output.
* `jobs` - **listing** [databricks_job](../resources/job.md). Usually, there are more automated workflows than interactive clusters, so they get their own file in this tool's output. *Please note that workflows deployed and maintained via [Databricks Asset Bundles](https://docs.databricks.com/en/dev-tools/bundles/index.html) aren't exported!*
* `mlflow-webhooks` - **listing** [databricks_mlflow_webhook](../resources/mlflow_webhook.md).
* `model-serving` - **listing** [databricks_model_serving](../resources/model_serving.md).
* `mounts` - **listing** works only in combination with `-mounts` command-line option.
Expand Down
12 changes: 11 additions & 1 deletion exporter/importables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/databricks/databricks-sdk-go/service/catalog"
"github.com/databricks/databricks-sdk-go/service/compute"
"github.com/databricks/databricks-sdk-go/service/iam"
sdk_jobs "github.com/databricks/databricks-sdk-go/service/jobs"
"github.com/databricks/databricks-sdk-go/service/sharing"
sdk_workspace "github.com/databricks/databricks-sdk-go/service/workspace"
tfcatalog "github.com/databricks/terraform-provider-databricks/catalog"
Expand Down Expand Up @@ -434,7 +435,7 @@ func TestInstnacePoolsListWithMatch(t *testing.T) {
})
}

func TestJobListNoNameMatch(t *testing.T) {
func TestJobListNoNameMatchOrFromBundles(t *testing.T) {
ic := importContextForTest()
ic.match = "bcd"
ic.importJobs([]jobs.Job{
Expand All @@ -443,6 +444,15 @@ func TestJobListNoNameMatch(t *testing.T) {
Name: "abc",
},
},
{
Settings: &jobs.JobSettings{
Name: "bcd",
EditMode: "UI_LOCKED",
Deployment: &sdk_jobs.JobDeployment{
Kind: "BUNDLE",
},
},
},
})
assert.Equal(t, 0, len(ic.testEmits))
}
Expand Down
5 changes: 5 additions & 0 deletions exporter/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,11 @@ func (ic *importContext) importJobs(l []jobs.Job) {
log.Printf("[INFO] Job name %s doesn't match selection %s", job.Settings.Name, ic.match)
continue
}
if job.Settings.Deployment != nil && job.Settings.Deployment.Kind == "BUNDLE" &&
job.Settings.EditMode == "UI_LOCKED" {
log.Printf("[INFO] Skipping job '%s' because it's deployed by DABs", job.Settings.Name)
continue
}
ic.Emit(&resource{
Resource: "databricks_job",
ID: job.ID(),
Expand Down

0 comments on commit 0110db5

Please sign in to comment.