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

Provide data resources that allows to query all jobs from within a project and or environment #274

Closed
mlavaert opened this issue Jul 9, 2024 · 3 comments · Fixed by #276
Labels
enhancement New feature or request

Comments

@mlavaert
Copy link

mlavaert commented Jul 9, 2024

Currently there is only a data object to get information from a single job. I would need to be able to query all jobs that exist in the production environment.

My use case:

  • I want to attach webhooks and notifications to jobs created outside of Terraform. Some teams have developer permissions allowing them to create their own jobs without going throughus.
@mlavaert mlavaert added the enhancement New feature or request label Jul 9, 2024
@b-per
Copy link
Collaborator

b-per commented Jul 9, 2024

Thanks for raising this!

I actually got the same feedback a few days ago from another user of the provider.

My first answer was to provide an example with the http datasource.

data "http" "my_jobs" {
  url = "https://emea.dbt.com/api/v2/accounts/<your-account-id>/jobs/?project_id=<your-project-id>&include_related=[environment]"

  request_headers = {
    Authorization = "Bearer ${var.dbt_token}"
  }
}

locals {
  my_jobs = jsondecode(data.http.my_jobs.response_body)
  my_jobs_prod = [for job in local.my_jobs.data : job if job.environment.deployment_type == "production"]
}

With the caveat that it will only return the first 100 jobs and will not work if there are more than 100 jobs in a given project.

But I am planning in adding a new datasource for dbtcloud_jobs.
What parameters would be useful for you? I was thinking of allowing filtering the data source byproject_id or environment_id.

@mlavaert
Copy link
Author

mlavaert commented Jul 9, 2024

That would work! TY

@b-per b-per closed this as completed Jul 17, 2024
@b-per
Copy link
Collaborator

b-per commented Jul 17, 2024

dbtcloud_jobs is available in 0.3.10 that is getting released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants