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

dbtcloud_job keeps trying to change custom_branch_only value #239

Closed justbldwn closed 3 months ago

justbldwn commented 4 months ago

Describe the bug

We have a module for managing our dbt Cloud projects, with a resource in the module to set up a dbtcloud_job In it, we have the following triggers defined:

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

Each time a Terraform run occurs, we're seeing an update for our dbtcloud_job resource trying to change custom_branch_only from false to true on every project in each environment defined in our Terraform workspace, even though it isn't set with a custom_branch_only as false anywhere. Below is an example plan we're seeing:

module.my_project.dbtcloud_job.generate_docs["dev"]

id : "123"
name : "Generate Docs"
~ triggers : {
    ~ custom_branch_only : false -> true
    git_provider_webhook : false
    github_webhook : false
    schedule : true
  }

When I go to the dbt Cloud UI, the configuration looks correct (the job is set to use a custom branch and the custom branch name defined.

dbtcloud_job_custom_branch

If I immediately re-plan in our workspace after applying, all dbtcloud_job.generate_docs resources want to be updated with the custom_branch_only : false -> true change all over again.

Is this something wrong with our configuration in the triggers section? Is there somewhere the custom_branch_only: false value is getting pulled from that may need to be updated? It's causing a lot of clutter in our Terraform workspace since it is trying to make hundreds of unnecessary updates each time we trigger a plan/apply in the workspace.

Terraform version: 1.5.2 dbt Cloud provider version: ~> 0.2.0

Any help here would be greatly appreciated, thanks!

b-per commented 3 months ago

Hi!

custom_branch_only at the job level has been deprecated from the dbt Cloud API recently: (docs).

So, if we try to set a value true for the field, we get some odd behaviour as you could see.

Could you set "custom_branch_only" : false, in your module?

I can add some comments in the docs about this particular field not being used anymore.

justbldwn commented 3 months ago

thanks, I appreciate the response. if we set custom_branch_only to false, are we able to still set a custom branch to point at for the job?

b-per commented 3 months ago

Yes.

justbldwn commented 3 months ago

great, thanks a lot for confirming. we've gone ahead and defaulted this to false in our module. will there be a point where custom_branch_only references should be removed entirely?

b-per commented 3 months ago

Yes, I will create a separate issue to make this field optional in the next version of the provider.

I will update the docs as well to reflect that the parameter has been deprecated.