Skip to content

Latest commit

 

History

History
80 lines (58 loc) · 4.05 KB

workspace_file.md

File metadata and controls

80 lines (58 loc) · 4.05 KB
subcategory
Workspace

databricks_workspace_file Resource

This resource allows you to manage Databricks Workspace Files.

Example Usage

You can declare Terraform-managed workspace file by specifying source attribute of corresponding local file.

data "databricks_current_user" "me" {
}

resource "databricks_workspace_file" "module" {
  source = "${path.module}/module.py"
  path   = "${data.databricks_current_user.me.home}/AA/BB/CC"
}

You can also create a managed workspace file with inline sources through content_base64 attribute.

resource "databricks_workspace_file" "init_script" {
  content_base64 = base64encode(<<-EOT
    #!/bin/bash
    echo "Hello World"
    EOT
  )
  path = "/Shared/init-script.sh"
}

Argument Reference

-> Note Files in Databricks workspace would only be changed, if Terraform stage did change. This means that any manual changes to managed workspace files won't be overwritten by Terraform, if there's no local change to file sources. Workspace files are identified by their path, so changing file's name manually on the workspace and then applying Terraform state would result in creation of workspace file from Terraform state.

The size of a workspace file source code must not exceed a few megabytes. The following arguments are supported:

  • path - (Required) The absolute path of the workspace file, beginning with "/", e.g. "/Demo".
  • source - Path to file on local filesystem. Conflicts with content_base64.
  • content_base64 - The base64-encoded file content. 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 workspace file with configuration properties for a data pipeline.

Attribute Reference

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

  • id - Path of workspace file
  • url - Routable URL of the workspace file
  • object_id - Unique identifier for a workspace file
  • workspace_path - path on Workspace File System (WSFS) in form of /Workspace + path

Access Control

Import

The workspace file resource can be imported using workspace file path

terraform import databricks_workspace_file.this /path/to/file

Related Resources

The following resources are often used in the same context: