This resource allows you to manage Databricks Notebooks. You can also work with databricks_notebook and databricks_notebook_paths data sources.
You can declare Terraform-managed notebook by specifying source
attribute of corresponding local file. Only .scala
, .py
, .sql
, .r
, and .ipynb
extensions are supported, if you would like to omit the language
attribute.
data "databricks_current_user" "me" {
}
resource "databricks_notebook" "ddl" {
source = "${path.module}/DDLgen.py"
path = "${data.databricks_current_user.me.home}/AA/BB/CC"
}
You can also create a managed notebook with inline sources through content_base64
and language
attributes.
resource "databricks_notebook" "notebook" {
content_base64 = base64encode(<<-EOT
# created from ${abspath(path.module)}
display(spark.range(10))
EOT
)
path = "/Shared/Demo"
language = "PYTHON"
}
You can also manage Databricks Archives to import the whole folders of notebooks statically. Whenever you update the .dbc
file, the Terraform-managed notebook folder is removed and replaced with contents of the new .dbc
file. You are strongly advised to use .dbc
format only with source
attribute of the resource:
resource "databricks_notebook" "lesson" {
source = "${path.module}/IntroNotebooks.dbc"
path = "/Shared/Intro"
}
The size of a notebook source code must not exceed a few megabytes. The following arguments are supported:
path
- (Required) The absolute path of the notebook or directory, beginning with "/", e.g. "/Demo".source
- Path to notebook in source code format on local filesystem. Conflicts with content_base64
.content_base64
- The base64-encoded notebook source code. Conflicts with source
. Use of content_base64
is discouraged, as it's increasing memory footprint of Terraform state and should only be used in exceptional circumstances, like creating a notebook with configuration properties for a data pipeline.language
- (required with content_base64
) One of SCALA
, PYTHON
, SQL
, R
.In addition to all arguments above, the following attributes are exported:
id
- Path of notebook on workspaceurl
- Routable URL of the notebookobject_id
- Unique identifier for a NOTEBOOKThe resource notebook can be imported using notebook path
terraform import databricks_notebook.this /path/to/notebook
The following resources are often used in the same context: