databricksdbfsfile Resource
June 12, 2026 ยท View on GitHub
-> Please switch to databricks_file or databricks_workspace_file to manage files. Databricks recommends against storing any production data or sensitive information in the DBFS root.
This is a resource that lets you manage relatively small files on Databricks File System (DBFS). The best use cases are libraries for databricks_cluster or databricks_job. You can also use databricks_dbfs_file and databricks_dbfs_file_paths data sources.
-> This resource can only be used with a workspace-level provider!
Example Usage
In order to manage a file on Databricks File System with Terraform, you must specify the source attribute containing the full path to the file on the local filesystem.
resource "databricks_dbfs_file" "this" {
source = "${path.module}/main.tf"
path = "/tmp/main.tf"
}
Alternatively, you can create DBFS files with custom content, using filesystem functions.
resource "databricks_dbfs_file" "this" {
content_base64 = base64encode(<<-EOT
Hello, world!
Module is ${abspath(path.module)}
EOT
)
path = "/tmp/this.txt"
}
Install databricks_library on all databricks_clusters:
data "databricks_clusters" "all" {
}
resource "databricks_dbfs_file" "app" {
source = "${path.module}/baz.whl"
path = "/FileStore/baz.whl"
}
resource "databricks_library" "app" {
for_each = data.databricks_clusters.all.ids
cluster_id = each.key
whl = databricks_dbfs_file.app.dbfs_path
}
Argument Reference
-> DBFS files would only be changed, if Terraform stage did change. This means that any manual changes to managed file won't be overwritten by Terraform, if there's no local change.
The following arguments are supported:
source- The full absolute path to the file. Conflicts withcontent_base64.content_base64- Encoded file contents. Conflicts withsource. Use ofcontent_base64is discouraged, as it's increasing memory footprint of Terraform state and should only be used in exceptional circumstances, like creating a data pipeline configuration file.path- (Required) The path of the file in which you wish to save.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- Same aspath.file_size- The file size of the file that is being tracked by this resource in bytes.dbfs_path- Path, but withdbfs:prefix.
Import
The resource dbfs file can be imported using the path of the file:
import {
to = databricks_dbfs_file.this
id = "<path>"
}
Alternatively, when using terraform version 1.4 or earlier, import using the terraform import command:
terraform import databricks_dbfs_file.this <path>
Related Resources
The following resources are often used in the same context:
- End to end workspace management guide.
- databricks_dbfs_file data to get file content from Databricks File System (DBFS).
- databricks_dbfs_file_paths data to get list of file names from get file content from Databricks File System (DBFS).
- databricks_global_init_script to manage global init scripts, which are run on all databricks_cluster and databricks_job.
- databricks_library to install a library on databricks_cluster.
- databricks_mount to mount your cloud storage on
dbfs:/mnt/name. - databricks_workspace_conf to manage workspace configuration for expert usage.