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

Provider produced inconsistent result after apply `dbtcloud_job` #259

Closed ryan-keswick closed 1 month ago

ryan-keswick commented 1 month ago

Describe the bug

Getting This is a bug in the provider, which should be reported in the provider's own issue tracker. when trying to apply

Error message

The error message from running terraform.

Resource configuration

resource "dbtcloud_job" "dw_refresh" {
  name = "au3 DW Full Refresh"

  environment_id = dbtcloud_environment.daisee.environment_id

  description = "The refreshing dims facts on Sunday"

  execute_steps = [
    "dbt seed",
    "dbt run --select \"models/01_staging/stg_*\" --full-refresh",
    "dbt run --select \"models/02_dims_facts\" --full-refresh",
  ]

  generate_docs = false

  is_active = false

  num_threads = 4

  project_id = data.dbtcloud_project.foo.id

  run_generate_sources = false

  # UTC Time
  schedule_type = "custom_cron"
  # “At 20:00 on Saturday.” See: https://crontab.guru/#0_20_*_*_6
  schedule_cron = "0 20 * * 6"

  target_name = "default"

  timeout_seconds = (12 * 60 * 60)

  triggers = {
    "git_provider_webhook" = false
    "github_webhook"       = false
    "schedule"             = true
  }

  triggers_on_draft_pr = false
}

Expected behavior

The dbt cloud job to be created

Config (please complete the following information):

$ terraform providers

Providers required by configuration:
.
└── module.dbt
    ├── provider[registry.terraform.io/snowflake-labs/snowflake] ~> 0.91.0
    ├── provider[registry.terraform.io/hashicorp/aws] ~> 5.30.0
    ├── provider[registry.terraform.io/dbt-labs/dbtcloud] ~> 0.3.5
    ├── provider[registry.terraform.io/hashicorp/random]
    ├── provider[registry.terraform.io/hashicorp/time]
    └── provider[terraform.io/builtin/terraform]

Providers required by state:

    provider[registry.terraform.io/dbt-labs/dbtcloud]

    provider[registry.terraform.io/hashicorp/random]

    provider[registry.terraform.io/hashicorp/time]

    provider[registry.terraform.io/snowflake-labs/snowflake]

    provider[terraform.io/builtin/terraform]
b-per commented 1 month ago

Thanks for the report @ryan-keswick . Looking at it now.

b-per commented 1 month ago

OK, so the issue is that you have is_active = false, which creates the job in a deleted state.

This field has been here historically but should never be set to false actually. I will try to remove it in the future but I need to be aware that some people will still have it in their config. I will also make the docs clearer that it should never be set to false.

The docs explain that if you want to create a job in a deactivated state, all triggers should be set to false instead.

is_active (Boolean) Flag for whether the job is marked active or deleted. To create/keep a job in a 'deactivated' state, check the triggers config.