Skip to content

Latest commit

 

History

History
95 lines (69 loc) · 4.64 KB

File metadata and controls

95 lines (69 loc) · 4.64 KB
subcategory Workspace

databricks_workspace_file Resource

API Documentation

This resource allows you to manage Databricks Workspace Files.

-> This resource can only be used with a workspace-level provider!

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

-> 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.
  • provider_config - (Optional) Configure the provider for management through account provider. This block consists of the following fields:
    • workspace_id - (Required) Workspace ID which the resource belongs to. This workspace must be part of the account which the provider is configured with.

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

import {
  to = databricks_workspace_file.this
  id = "/path/to/file"
}

Alternatively, when using terraform version 1.4 or earlier, import using the terraform import command:

terraform import databricks_workspace_file.this /path/to/file

Related Resources

The following resources are often used in the same context: