Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added databricks_jobs data resource #1138

Merged
merged 2 commits into from
Feb 25, 2022
Merged

Added databricks_jobs data resource #1138

merged 2 commits into from
Feb 25, 2022

Conversation

nfx
Copy link
Contributor

@nfx nfx commented Feb 23, 2022

Retrieves a list of databricks_job ids, that were created by Terraform or manually, so that special handling could be applied.

-> Note Data resource will error in case of jobs with duplicate names.

Example Usage

Granting view databricks_permissions to all databricks_job within the workspace:

data "databricks_jobs" "this" {}

resource "databricks_permissions" "everyone_can_view_all_jobs" {
  for_each = data.databricks_jobs.this.ids
  job_id   = each.value

  access_control {
    group_name       = "users"
    permission_level = "CAN_VIEW"
  }
}

Getting ID of specific databricks_job by name:

data "databricks_jobs" "this" {}

output "x" {
  value     = "ID of `x` job is ${data.databricks_jobs.this.ids["x"]}"
  sensitive = false
}

Fixes #1075

@nfx nfx requested a review from alexott February 23, 2022 13:32
@codecov
Copy link

codecov bot commented Feb 23, 2022

Codecov Report

Merging #1138 (7a7428d) into master (83a5ea5) will decrease coverage by 0.00%.
The diff coverage is 89.74%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1138      +/-   ##
==========================================
- Coverage   90.80%   90.79%   -0.01%     
==========================================
  Files         113      114       +1     
  Lines        9655     9692      +37     
==========================================
+ Hits         8767     8800      +33     
- Misses        524      526       +2     
- Partials      364      366       +2     
Impacted Files Coverage Δ
jobs/data_jobs.go 71.42% <71.42%> (ø)
common/reflect_resource.go 93.38% <100.00%> (+0.11%) ⬆️
common/resource.go 87.00% <100.00%> (+2.29%) ⬆️
provider/provider.go 94.69% <100.00%> (+0.04%) ⬆️
qa/testing.go 86.98% <100.00%> (ø)

nfx added 2 commits February 25, 2022 20:30
## Example Usage

Granting view [databricks_permissions](../resources/permissions.md) to all [databricks_job](../resources/job.md) within the workspace:

```hcl
data "databricks_jobs" "this" {}

resource "databricks_permissions" "everyone_can_view_all_jobs" {
  for_each = data.databricks_jobs.this.ids
  job_id   = each.value

  access_control {
    group_name       = "users"
    permission_level = "CAN_VIEW"
  }
}
```

Getting ID of specific [databricks_job](../resources/job.md) by name:

```hcl
data "databricks_jobs" "this" {}

output "x" {
  value     = "ID of `x` job is ${data.databricks_jobs.this.ids["x"]}"
  sensitive = false
}
```
@nfx nfx merged commit 67dea81 into master Feb 25, 2022
@nfx nfx deleted the issue/1075 branch February 25, 2022 19:49
@nfx nfx mentioned this pull request Feb 25, 2022
michael-berk pushed a commit to michael-berk/terraform-provider-databricks that referenced this pull request Feb 15, 2023
Retrieves a list of databricks_job ids, that were created by Terraform or manually, so that special handling could be applied.

## Example Usage

Granting view [databricks_permissions](../resources/permissions.md) to all [databricks_job](../resources/job.md) within the workspace:

```hcl
data "databricks_jobs" "this" {}

resource "databricks_permissions" "everyone_can_view_all_jobs" {
  for_each = data.databricks_jobs.this.ids
  job_id   = each.value

  access_control {
    group_name       = "users"
    permission_level = "CAN_VIEW"
  }
}
```

Getting ID of specific [databricks_job](../resources/job.md) by name:

```hcl
data "databricks_jobs" "this" {}

output "x" {
  value     = "ID of `x` job is ${data.databricks_jobs.this.ids["x"]}"
  sensitive = false
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] Data Resource Request for Jobs
1 participant