dbt-labs / terraform-provider-dbtcloud

dbt Cloud Terraform Provider
https://registry.terraform.io/providers/dbt-labs/dbtcloud
MIT License
80 stars 18 forks source link

Allow for Creation of Continuous Integration Job #193

Closed anaghshineh closed 9 months ago

anaghshineh commented 9 months ago

Do we have a way to create jobs of Continuous Integration type via this provider? Doesn't look like it based on the docs/API endpoints, so wanted to put this forth as a feature request! Would love to use this provider to automate the creation of an environment with CI jobs.

b-per commented 9 months ago

Hi!

Have you checked dbtcloud_job and the fields under triggers?

I believe that setting the following should work (just tweak the custom branch field according to your needs):

  triggers = {
    "custom_branch_only" : true,
    "github_webhook" : true,
    "git_provider_webhook" : true,
    "schedule" : false
  }

Let me know if it works!

anaghshineh commented 9 months ago

Oh, great - I'll give this a shot and follow up within a week or so. Thank you!

anaghshineh commented 9 months ago

Hey, @b-per! I finally got around to testing this out. I was able to create a job that runs on pull request, but I'm unfortunately not seeing a way to set the deferral environment. See the screenshot - it's defaulting to setting no deferral environment. Would be great for this to be configurable.

image

I think the create job endpoint needs to be updated to allow for this, and then the Terraform provider code updated to support that?

Thank you ❤️

b-per commented 9 months ago

The API and the latest version of the provider let you do it. If you look here https://registry.terraform.io/providers/dbt-labs/dbtcloud/latest/docs/resources/job#deferring_environment_id , you have the ability to provide which environment ID the job should defer to.

Let me know if it works!

anaghshineh commented 9 months ago

Ah, totally missed that. Thanks a bunch - I'm going to give this a try in the next few days.

b-per commented 9 months ago

Feel free to reopen if this is not working as expected