Skip to content

Latest commit

 

History

History
58 lines (44 loc) · 1.69 KB

File metadata and controls

58 lines (44 loc) · 1.69 KB

databricks_current_user Data Source

Retrieves information about databricks_user or databricks_service_principal, that is calling Databricks REST API. Might be useful in applying the same Terraform by different users in the shared workspace for testing purposes.

Example Usage

Create personalized databricks_job and databricks_notebook:

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}/Terraform"
  language = "PYTHON"
  content_base64 = base64encode(<<-EOT
    # created from ${abspath(path.module)}
    display(spark.range(10))
    EOT
  )
}

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

  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
  }

  email_notifications {}
}

output "notebook_url" {
  value = databricks_notebook.this.url
}

output "job_url" {
  value = databricks_job.this.url
}

Exported attributes

Data source exposes the following attributes:

  • id - The id of the calling user.
  • user_name - Name of the user, e.g. mr.foo@example.com.
  • home - Home folder of the user, e.g. /Users/mr.foo@example.com.
  • alphanumeric - Alphanumeric representation of user local name. e.g. mr_foo.