databricks_mlflow_webhook Resource

This resource allows you to create MLflow Model Registry Webhooks in Databricks. Webhooks enable you to listen for Model Registry events so your integrations can automatically trigger actions. You can use webhooks to automate and integrate your machine learning pipeline with existing CI/CD tools and workflows. Webhooks allow trigger execution of a Databricks job or call a web service on specific event(s) that is generated in the MLflow Registry - stage transitioning, creation of registered model, creation of transition request, etc.

Example Usage

Triggering Databricks job

data "databricks_current_user" "me" {}
data "databricks_spark_version" "latest" {}
data "databricks_node_type" "smallest" {
  local_disk = true
}

resource "databricks_notebook" "this" {
  path     = "${data.databricks_current_user.me.home}/MLFlowWebhook"
  language = "PYTHON"
  content_base64 = base64encode(<<-EOT
    import json

    event_message = dbutils.widgets.get("event_message")
    event_message_dict = json.loads(event_message)
    print(f"event data={event_message_dict}")
    EOT
  )
}

resource "databricks_job" "this" {
  name = "Terraform MLflowWebhook Demo (${data.databricks_current_user.me.alphanumeric})"

  task {
    task_key = "task1"

    new_cluster {
      num_workers   = 1
      spark_version = data.databricks_spark_version.latest.id
      node_type_id  = data.databricks_node_type.smallest.id
    }

    notebook_task {
      notebook_path = databricks_notebook.this.path
    }
  }
}

resource "databricks_token" "pat_for_webhook" {
  comment          = "MLflow Webhook"
  lifetime_seconds = 86400000
}

resource "databricks_mlflow_webhook" "job" {
  events      = ["TRANSITION_REQUEST_CREATED"]
  description = "Databricks Job webhook trigger"
  status      = "ACTIVE"
  job_spec {
    job_id        = databricks_job.this.id
    workspace_url = data.databricks_current_user.me.workspace_url
    access_token  = databricks_token.pat_for_webhook.token_value
  }
}

POSTing to URL

resource "databricks_mlflow_webhook" "url" {
  events      = ["TRANSITION_REQUEST_CREATED"]
  description = "URL webhook trigger"
  http_url_spec {
    url = "https://my_cool_host/webhook"
  }
}

Argument Reference

The following arguments are supported:

Configuration must include one of http_url_spec or job_spec blocks, but not both.

job_spec

http_url_spec

Attribute Reference

In addition to all arguments above, the following attributes are exported:

Access Control

Import

The following resources are often used in the same context: