databricksglobalinit_script Resource
June 12, 2026 ยท View on GitHub
This resource allows you to manage global init scripts, which are run on all databricks_cluster and databricks_job.
-> This resource can only be used with a workspace-level provider!
Example Usage
You can declare Terraform-managed global init script by specifying source attribute of corresponding local file.
resource "databricks_global_init_script" "init1" {
source = "${path.module}/init.sh"
name = "my init script"
}
You can also create a managed global init script with inline sources through content_base64 attribute.
resource "databricks_global_init_script" "init2" {
content_base64 = base64encode(<<-EOT
#!/bin/bash
echo "hello world"
EOT
)
name = "hello script"
}
Argument Reference
-> Global init script in the Databricks workspace would only be changed, if Terraform stage did change. This means that any manual changes to managed global init script won't be overwritten by Terraform, if there's no local change to source.
The size of a global init script source code must not exceed 64Kb. The following arguments are supported:
name(string, required) - the name of the script. It should be uniquesource- Path to script's source code on local filesystem. Conflicts withcontent_base64content_base64- The base64-encoded source code global init script. Conflicts withsource. Use ofcontent_base64is discouraged, as it's increasing memory footprint of Terraform state and should only be used in exceptional circumstancesenabled(bool, optional default:false) specifies if the script is enabled for execution, or notposition(integer, optional default:null) - the position of a global init script, where0represents the first global init script to run,1is the second global init script to run, and so on. When omitted, the script gets the last position.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- ID assigned to a global init script by API
Access Control
Global init scripts are available only for administrators, so you can't change permissions for it.
Import
The resource global init script can be imported using script ID:
import {
to = databricks_global_init_script.this
id = "script_id"
}
Alternatively, when using terraform version 1.4 or earlier, import using the terraform import command:
terraform import databricks_global_init_script.this script_id
Related Resources
The following resources are often used in the same context:
- End to end workspace management guide.
- databricks_cluster to create Databricks Clusters.
- databricks_cluster_policy to create a databricks_cluster policy, which limits the ability to create clusters based on a set of rules.
- databricks_workspace_file to manage small files in Databricks workspace
- databricks_ip_access_list to allow access from predefined IP ranges.