|
| 1 | +--- |
| 2 | +subcategory: "Workspace" |
| 3 | +--- |
| 4 | +# databricks_workspace_file Resource |
| 5 | + |
| 6 | +This resource allows you to manage [Databricks Workspace Files](https://docs.databricks.com/files/workspace.html). |
| 7 | + |
| 8 | +## Example Usage |
| 9 | + |
| 10 | +You can declare Terraform-managed workspace file by specifying `source` attribute of corresponding local file. |
| 11 | + |
| 12 | +```hcl |
| 13 | +data "databricks_current_user" "me" { |
| 14 | +} |
| 15 | +
|
| 16 | +resource "databricks_workspace_file" "module" { |
| 17 | + source = "${path.module}/module.py" |
| 18 | + path = "${data.databricks_current_user.me.home}/AA/BB/CC" |
| 19 | +} |
| 20 | +``` |
| 21 | + |
| 22 | +You can also create a managed workspace file with inline sources through `content_base64` attribute. |
| 23 | + |
| 24 | +```hcl |
| 25 | +resource "databricks_workspace_file" "init_script" { |
| 26 | + content_base64 = base64encode(<<-EOT |
| 27 | + #!/bin/bash |
| 28 | + echo "Hello World" |
| 29 | + EOT |
| 30 | + ) |
| 31 | + path = "/Shared/init-script.sh" |
| 32 | +} |
| 33 | +``` |
| 34 | + |
| 35 | +## Argument Reference |
| 36 | + |
| 37 | +-> **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. |
| 38 | + |
| 39 | +The size of a workspace file source code must not exceed a few megabytes. The following arguments are supported: |
| 40 | + |
| 41 | +* `path` - (Required) The absolute path of the workspace file, beginning with "/", e.g. "/Demo". |
| 42 | +* `source` - Path to file on local filesystem. Conflicts with `content_base64`. |
| 43 | +* `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. |
| 44 | + |
| 45 | +## Attribute Reference |
| 46 | + |
| 47 | +In addition to all arguments above, the following attributes are exported: |
| 48 | + |
| 49 | +* `id` - Path of workspace file |
| 50 | +* `url` - Routable URL of the workspace file |
| 51 | +* `object_id` - Unique identifier for a workspace file |
| 52 | + |
| 53 | +## Access Control |
| 54 | + |
| 55 | +* [databricks_permissions](permissions.md#workspace-file-usage) can control which groups or individual users can access workspace file. |
| 56 | + |
| 57 | +## Import |
| 58 | + |
| 59 | +The workspace file resource can be imported using workspace file path |
| 60 | + |
| 61 | +```bash |
| 62 | +$ terraform import databricks_workspace_file.this /path/to/file |
| 63 | +``` |
| 64 | + |
| 65 | +## Related Resources |
| 66 | + |
| 67 | +The following resources are often used in the same context: |
| 68 | + |
| 69 | +* [End to end workspace management](../guides/workspace-management.md) guide. |
| 70 | +* [databricks_cluster](cluster.md) to create [Databricks Clusters](https://docs.databricks.com/clusters/index.html). |
| 71 | +* [databricks_directory](directory.md) to manage directories in [Databricks Workpace](https://docs.databricks.com/workspace/workspace-objects.html). |
| 72 | +* [databricks_job](job.md) to manage [Databricks Jobs](https://docs.databricks.com/jobs.html) to run non-interactive code in a [databricks_cluster](cluster.md). |
| 73 | +* [databricks_pipeline](pipeline.md) to deploy [Delta Live Tables](https://docs.databricks.com/data-engineering/delta-live-tables/index.html). |
| 74 | +* [databricks_repo](repo.md) to manage [Databricks Repos](https://docs.databricks.com/repos.html). |
| 75 | +* [databricks_secret](secret.md) to manage [secrets](https://docs.databricks.com/security/secrets/index.html#secrets-user-guide) in Databricks workspace. |
| 76 | +* [databricks_secret_acl](secret_acl.md) to manage access to [secrets](https://docs.databricks.com/security/secrets/index.html#secrets-user-guide) in Databricks workspace. |
| 77 | +* [databricks_secret_scope](secret_scope.md) to create [secret scopes](https://docs.databricks.com/security/secrets/index.html#secrets-user-guide) in Databricks workspace. |
| 78 | +* [databricks_user](user.md) to [manage users](https://docs.databricks.com/administration-guide/users-groups/users.html), that could be added to [databricks_group](group.md) within the workspace. |
| 79 | +* [databricks_user](../data-sources/user.md) data to retrieve information about [databricks_user](user.md). |
0 commit comments