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. |
auto_enforcement_config | object | If present, auto enforcement is enabled for the policy. After the policy is edited, a background operation may be scheduled to scan and edit all clusters and jobs using this policy to be in compliance with the policy. The background operation is created when a policy edit does one of the following: - Changes the policy definition, or - Changes auto enforcement from disabled to enabled Additionally, changes to the policy definition or auto enforcement configuration may cause an in-progress operation to be restarted. To cancel an in-progress operation, edit the policy to delete this auto enforcement configuration. The background operation status is reported via the ``background_enforcement`` field when reading the policy. |
background_enforcement | object | Status and results of the background auto-enforcement operation for this policy. Only returned if calling "Get a cluster policy" with ``POLICY_VIEW_FULL``. Must be a workspace admin for this field to be populated. |
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 <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 <https://docs.databricks.com/administration-guide/clusters/policy-definition.html>`__. 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. |
| 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. |
auto_enforcement_config | object | If present, auto enforcement is enabled for the policy. After the policy is edited, a background operation may be scheduled to scan and edit all clusters and jobs using this policy to be in compliance with the policy. The background operation is created when a policy edit does one of the following: - Changes the policy definition, or - Changes auto enforcement from disabled to enabled Additionally, changes to the policy definition or auto enforcement configuration may cause an in-progress operation to be restarted. To cancel an in-progress operation, edit the policy to delete this auto enforcement configuration. The background operation status is reported via the ``background_enforcement`` field when reading the policy. |
background_enforcement | object | Status and results of the background auto-enforcement operation for this policy. Only returned if calling "Get a cluster policy" with ``POLICY_VIEW_FULL``. Must be a workspace admin for this field to be populated. |
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 <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 <https://docs.databricks.com/administration-guide/clusters/policy-definition.html>`__. 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. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | policy_id, deployment_name | policy_view | 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. |
policy_view | string | Controls which fields are returned. |
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,
auto_enforcement_config,
background_enforcement,
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
AND policy_view = '{{ policy_view }}'
;
Returns a list of policies accessible by the requesting user.
SELECT
name,
policy_family_id,
policy_id,
creator_user_name,
auto_enforcement_config,
background_enforcement,
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 (
auto_enforcement_config,
definition,
description,
libraries,
max_clusters_per_user,
name,
policy_family_definition_overrides,
policy_family_id,
deployment_name
)
SELECT
'{{ auto_enforcement_config }}',
'{{ 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: auto_enforcement_config
description: |
If present, auto enforcement is enabled for the policy. After the policy is edited, a background operation may be scheduled to scan and edit all clusters and jobs using this policy to be in compliance with the policy. The background operation is created when a policy edit does one of the following: - Changes the policy definition, or - Changes auto enforcement from disabled to enabled Additionally, changes to the policy definition or auto enforcement configuration may cause an in-progress operation to be restarted. To cancel an in-progress operation, edit the policy to delete this auto enforcement configuration. The background operation status is reported via the ``background_enforcement`` field when reading the policy.
value:
enforce_mode: "{{ enforce_mode }}"
- name: definition
value: "{{ definition }}"
description: |
Policy definition document expressed in `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 <https://docs.databricks.com/administration-guide/clusters/policy-definition.html>`__. 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.
- 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 }}',
auto_enforcement_config = '{{ auto_enforcement_config }}',
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
;