cluster_policies
Creates, updates, deletes, gets or lists a cluster_policies resource.
Overview
| Name | cluster_policies |
| Type | Resource |
| Id | databricks_workspace.compute.cluster_policies |
Fields
The following fields are returned by SELECT queries:
- get
- list
| Name | Datatype | Description |
|---|---|---|
name | string | Cluster Policy name requested by the user. This has to be unique. Length must be between 1 and 100 characters. |
policy_family_id | string | ID 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_id | string | Canonical unique identifier for the Cluster Policy. |
creator_user_name | string | Creator user name. The field won't be included in the response if the user has already been deleted. |
created_at_timestamp | integer | Creation time. The timestamp (in millisecond) when this Cluster Policy was created. |
definition | string | Policy definition document expressed in [Databricks Cluster Policy Definition Language]. [Databricks Cluster Policy Definition Language]: https://docs.databricks.com/administration-guide/clusters/policy-definition.html |
description | string | Additional human-readable description of the cluster policy. |
is_default | boolean | If true, policy is a default policy created and managed by Databricks. Default policies cannot be deleted, and their policy families cannot be changed. |
libraries | array | A 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_user | integer | Max number of clusters per user that can be active using this policy. If not present, there is no max limit. |
policy_family_definition_overrides | string | Policy 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 |
| Name | Datatype | Description |
|---|---|---|
name | string | Cluster Policy name requested by the user. This has to be unique. Length must be between 1 and 100 characters. |
policy_family_id | string | ID 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_id | string | Canonical unique identifier for the Cluster Policy. |
creator_user_name | string | Creator user name. The field won't be included in the response if the user has already been deleted. |
created_at_timestamp | integer | Creation time. The timestamp (in millisecond) when this Cluster Policy was created. |
definition | string | Policy definition document expressed in [Databricks Cluster Policy Definition Language]. [Databricks Cluster Policy Definition Language]: https://docs.databricks.com/administration-guide/clusters/policy-definition.html |
description | string | Additional human-readable description of the cluster policy. |
is_default | boolean | If true, policy is a default policy created and managed by Databricks. Default policies cannot be deleted, and their policy families cannot be changed. |
libraries | array | A 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_user | integer | Max number of clusters per user that can be active using this policy. If not present, there is no max limit. |
policy_family_definition_overrides | string | Policy 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:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | policy_id, deployment_name | Get a cluster policy entity. Creation and editing is available to admins only. | |
list | select | deployment_name | sort_column, sort_order | Returns a list of policies accessible by the requesting user. |
create | insert | deployment_name | Creates a new policy with prescribed settings. | |
replace | replace | deployment_name, policy_id | Update an existing policy for cluster. This operation may make some clusters governed by the previous | |
delete | delete | deployment_name | Delete 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.
| Name | Datatype | Description |
|---|---|---|
deployment_name | string | The Databricks Workspace Deployment Name (default: dbc-abcd0123-a1bc) |
policy_id | string | Canonical unique identifier for the Cluster Policy. |
sort_column | string | The 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_order | string | The order in which the policies get listed. * DESC - Sort result list in descending order. * ASC - Sort result list in ascending order. |
SELECT examples
- get
- list
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
;
Returns a list of policies accessible by the requesting user.
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 deployment_name = '{{ deployment_name }}' -- required
AND sort_column = '{{ sort_column }}'
AND sort_order = '{{ sort_order }}'
;
INSERT examples
- create
- Manifest
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
;
# Description fields are for documentation purposes
- name: cluster_policies
props:
- name: deployment_name
value: "{{ deployment_name }}"
description: Required parameter for the cluster_policies resource.
- name: definition
value: "{{ definition }}"
description: |
Policy definition document expressed in [Databricks Cluster Policy Definition Language]. [Databricks Cluster Policy Definition Language]: https://docs.databricks.com/administration-guide/clusters/policy-definition.html
- name: description
value: "{{ description }}"
description: |
Additional human-readable description of the cluster policy.
- name: libraries
description: |
A list of libraries to be installed on the next cluster restart that uses this policy. The maximum number of libraries is 500.
value:
- cran:
package: "{{ package }}"
repo: "{{ repo }}"
egg: "{{ egg }}"
jar: "{{ jar }}"
maven:
coordinates: "{{ coordinates }}"
exclusions:
- "{{ exclusions }}"
repo: "{{ repo }}"
pypi:
package: "{{ package }}"
repo: "{{ repo }}"
requirements: "{{ requirements }}"
whl: "{{ whl }}"
- name: max_clusters_per_user
value: {{ max_clusters_per_user }}
description: |
Max number of clusters per user that can be active using this policy. If not present, there is no max limit.
- name: name
value: "{{ name }}"
description: |
Cluster Policy name requested by the user. This has to be unique. Length must be between 1 and 100 characters.
- name: policy_family_definition_overrides
value: "{{ policy_family_definition_overrides }}"
description: |
Policy 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
- name: policy_family_id
value: "{{ policy_family_id }}"
description: |
ID 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.
REPLACE examples
- replace
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
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
;