terraform-provider-databricks icon indicating copy to clipboard operation
terraform-provider-databricks copied to clipboard

[ISSUE] `databricks_job` prevents deleting on_start, on_failure, or on_success blocks from webhook_notifications

Open davejhahn opened this issue 2 years ago • 4 comments

Configuration

resource "databricks_job" "this" {

  max_concurrent_runs =1
  name = "test"
  retry_on_timeout = false
  timeout_seconds = 0

  webhook_notifications  {

    on_start  {
      id = var.webhook_id
    }

    on_failure  {
      id = var.webhook_id
    }

   on_success {
      id = var.webhook_id
    }
  }

  task {
    task_key = "test"
    existing_cluster_id = data.databricks_cluster.default.id

    notebook_task {
      notebook_path = "/Repos/REPOSITORYIDENTIFIER/MYREPO/MYNOTEBOOKPATH"
      source = "WORKSPACE"      
    }    
  }

}

Expected Behavior

When removing existing on_start, on_failure, or on_success blocks from webhook_notifications, it should remove the entire block.

Actual Behavior

Leaves removed block (such as on_success) and attempts to assign "" to the id resulting in an error.

Steps to Reproduce

  1. Run example above (updating notebook_path, var.webhook_id, and cluster od
  2. Comment out on_success block
  3. Run

Results in:

  ~ resource "databricks_job" "this" {
        id                        = "XXXX"
        name                      = "test"
        # (8 unchanged attributes hidden)

      ~ webhook_notifications {

          ~ on_success {
              - id = "XXX-XXX-XXX-XXX-XXXX" -> null
            }

            # (2 unchanged blocks hidden)
        }

        # (2 unchanged blocks hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

databricks_job.this: Modifying... [id=XXX]
╷
│ Error: cannot update job: Webhook with id '' was not found.
│
│   with databricks_job.this,
│   on main.tf line 33, in resource "databricks_job" "this":
│   33: resource "databricks_job" "this" {

Terraform and provider versions

davejhahn avatar Mar 16 '23 19:03 davejhahn

Hello,

I also have this error. Is there any news on this?

Francisco Vieira

fdvieira avatar Jun 28 '23 09:06 fdvieira

I think this is related, but when I attempt to delete the entire webhook_notification block it will also assign the previous values to null, then complain that those fields can't be null. Seems it's not possible to remove a webhook from the terraform resource once it is added.

glangho avatar Jan 19 '24 16:01 glangho

I ran into the exact same issue today. For email_notifications, destroying it does work. For webhook_notifications it does not. This makes setting webhook notifcations from terraform impossible to manage. Any news on this would be appreciated?

thijs-nijhuis avatar Mar 01 '24 10:03 thijs-nijhuis

@mgyucht - https://github.com/databricks/terraform-provider-databricks/pull/3309 should fix this?

alexott avatar Mar 01 '24 15:03 alexott