Skip to main content

cluster_policies

Creates, updates, deletes, gets or lists a cluster_policies resource.

Overview

Namecluster_policies
TypeResource
Iddatabricks_workspace.compute.cluster_policies

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
namestringCluster Policy name requested by the user. This has to be unique. Length must be between 1 and 100 characters.
policy_family_idstringID of the policy family. The cluster policy's policy definition inherits the policy family's policy definition. Cannot be used with `definition`. Use `policy_family_definition_overrides` instead to customize the policy definition.
policy_idstringCanonical unique identifier for the Cluster Policy.
creator_user_namestringCreator user name. The field won't be included in the response if the user has already been deleted.
created_at_timestampintegerCreation time. The timestamp (in millisecond) when this Cluster Policy was created.
definitionstringPolicy definition document expressed in [Databricks Cluster Policy Definition Language]. [Databricks Cluster Policy Definition Language]: https://docs.databricks.com/administration-guide/clusters/policy-definition.html
descriptionstringAdditional human-readable description of the cluster policy.
is_defaultbooleanIf true, policy is a default policy created and managed by Databricks. Default policies cannot be deleted, and their policy families cannot be changed.
librariesarrayA list of libraries to be installed on the next cluster restart that uses this policy. The maximum number of libraries is 500.
max_clusters_per_userintegerMax number of clusters per user that can be active using this policy. If not present, there is no max limit.
policy_family_definition_overridesstringPolicy definition JSON document expressed in [Databricks Policy Definition Language]. The JSON document must be passed as a string and cannot be embedded in the requests. You can use this to customize the policy definition inherited from the policy family. Policy rules specified here are merged into the inherited policy definition. [Databricks Policy Definition Language]: https://docs.databricks.com/administration-guide/clusters/policy-definition.html

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectpolicy_id, deployment_nameGet a cluster policy entity. Creation and editing is available to admins only.
listselectdeployment_namesort_column, sort_orderReturns a list of policies accessible by the requesting user.
createinsertdeployment_nameCreates a new policy with prescribed settings.
replacereplacedeployment_name, policy_idUpdate an existing policy for cluster. This operation may make some clusters governed by the previous
deletedeletedeployment_nameDelete a policy for a cluster. Clusters governed by this policy can still run, but cannot be edited.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
deployment_namestringThe Databricks Workspace Deployment Name (default: dbc-abcd0123-a1bc)
policy_idstringCanonical unique identifier for the Cluster Policy.
sort_columnstringThe cluster policy attribute to sort by. * POLICY_CREATION_TIME - Sort result list by policy creation time. * POLICY_NAME - Sort result list by policy name.
sort_orderstringThe order in which the policies get listed. * DESC - Sort result list in descending order. * ASC - Sort result list in ascending order.

SELECT examples

Get a cluster policy entity. Creation and editing is available to admins only.

SELECT
name,
policy_family_id,
policy_id,
creator_user_name,
created_at_timestamp,
definition,
description,
is_default,
libraries,
max_clusters_per_user,
policy_family_definition_overrides
FROM databricks_workspace.compute.cluster_policies
WHERE policy_id = '{{ policy_id }}' -- required
AND deployment_name = '{{ deployment_name }}' -- required
;

INSERT examples

Creates a new policy with prescribed settings.

INSERT INTO databricks_workspace.compute.cluster_policies (
definition,
description,
libraries,
max_clusters_per_user,
name,
policy_family_definition_overrides,
policy_family_id,
deployment_name
)
SELECT
'{{ definition }}',
'{{ description }}',
'{{ libraries }}',
{{ max_clusters_per_user }},
'{{ name }}',
'{{ policy_family_definition_overrides }}',
'{{ policy_family_id }}',
'{{ deployment_name }}'
RETURNING
policy_id
;

REPLACE examples

Update an existing policy for cluster. This operation may make some clusters governed by the previous

REPLACE databricks_workspace.compute.cluster_policies
SET
policy_id = '{{ policy_id }}',
definition = '{{ definition }}',
description = '{{ description }}',
libraries = '{{ libraries }}',
max_clusters_per_user = {{ max_clusters_per_user }},
name = '{{ name }}',
policy_family_definition_overrides = '{{ policy_family_definition_overrides }}',
policy_family_id = '{{ policy_family_id }}'
WHERE
deployment_name = '{{ deployment_name }}' --required
AND policy_id = '{{ policy_id }}' --required;

DELETE examples

Delete a policy for a cluster. Clusters governed by this policy can still run, but cannot be edited.

DELETE FROM databricks_workspace.compute.cluster_policies
WHERE deployment_name = '{{ deployment_name }}' --required
;