---
title: Create and manage classic compute policies
description: Create and manage classic compute policies to control cluster configuration and creation permissions for users and groups in your workspace.
canonical_url: https://docs.databricks.com/aws/en/admin/clusters/policies
---

# Create and manage classic compute policies

This page explains how to create and manage policies for classic compute in your workspace. For information on writing policy definitions, see [Compute policy reference](https://docs.databricks.com/aws/en/admin/clusters/policy-definition.md). For serverless compute policies, see [Manage serverless compute policies](https://docs.databricks.com/aws/en/admin/compute-policies/serverless.md).

## What are compute policies?

A policy is a tool workspace admins can use to limit a user or group's compute creation permissions based on a set of policy rules.

Policies provide the following benefits:

* Limit users to creating clusters with prescribed settings.
* Limit users to creating a certain number of clusters.
* Simplify the user interface and enable more users to create their own clusters (by fixing and hiding some values).
* Control cost by limiting per-cluster maximum cost (by setting limits on attributes whose values contribute to hourly price).
* Enforce cluster-scoped library installations.

## Create a policy

> [!NOTE]
>
> These instructions use the policy UI, which allows you to configure policy definitions using dropdown menus and other UI elements. You can also edit the full policy definition as JSON. For more information, see [Configure policy definitions using UI elements](https://docs.databricks.com/aws/en/admin/clusters/policy-definition.md#new-form).

To create a policy:

1. Click ![compute icon](https://docs.databricks.com/aws/en/images/icons/compute-icon.png) **Compute** in the sidebar.
2. Click the **Policies** tab.
3. Click **Create policy**.
4. Name the policy. Policy names are case-insensitive.
5. Optionally, select a policy family from the **Family** dropdown. This determines the template from which you build the policy.
6. Enter a **Description** of the policy. This helps others know the purpose of the policy.
7. Under **Advanced options**, you can specify the cluster type, max compute resources per user, and max DBUs per hour.
8. In the **Definitions** tab, add new definitions or edit inherited definitions. Add JSON rules in the **Advanced options** section, or click the **Edit definition as JSON** button to edit the entire policy definition as JSON.
9. In the **Tags** section, define rules around custom tags
10. In the **Libraries** tab, add any compute-scoped libraries that you want the policy to install on the compute. See [Add libraries to a policy](https://docs.databricks.com/aws/en/admin/clusters/policies.md#libraries).
11. Click **Create**.

To update the policy permissions, open the policy's overview page and click **See all permissions** to open the permissions modal.

### <a id="family" />Use a policy family

When you create a policy, you can choose to use a policy family. Policy families are Databricks-provided policy templates with pre-populated rules, designed to address common compute use cases.

When using a policy family, the rules for your policy are inherited from the policy family. After selecting a policy family, you can create the policy as-is, or choose to add rules or override the given rules. For more on policy families, see [Default policies and policy families](https://docs.databricks.com/aws/en/admin/clusters/policy-families.md).

### <a id="libraries" />Add libraries to a policy

You can add [libraries](https://docs.databricks.com/aws/en/libraries/index.md) to a policy so libraries are automatically installed on compute resources. You can add a maximum of 500 libraries to a policy.

> [!NOTE]
>
> You may have previously added compute-scoped libraries using init scripts. Databricks recommends using compute policies instead of init scripts to install libraries.

To add a library to your policy:

1. At the bottom of the **Create policy** page, click the **Libraries** tab.

2. Click **Add library**.

3. Select one of the **Library Source** options, then follow the instructions as outlined below:

   | Library source        | Instructions                                                                                                                                                                                                                                                     |
   | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
   | **Workspace**         | Select a workspace file or upload a Whl, zipped wheelhouse (with `*.wheelhouse.whl` extension), JAR, ZIP, tar, or requirements.txt file. See [Install libraries from workspace files](https://docs.databricks.com/aws/en/libraries/workspace-files-libraries.md) |
   | **Volumes**           | Select a Whl, JAR, or requirements.txt file from a volume. See [Install libraries from a volume](https://docs.databricks.com/aws/en/libraries/volume-libraries.md).                                                                                              |
   | **File Path/S3**      | Select the library type and provide the full URI to the library object (for example: `s3://bucket-name/path/to/library.whl`). See [Install libraries from object storage](https://docs.databricks.com/aws/en/libraries/object-storage-libraries.md).             |
   | **PyPI**              | Enter a PyPI package name. See [PyPI package](https://docs.databricks.com/aws/en/libraries/package-repositories.md#pypi-libraries).                                                                                                                              |
   | **Maven**             | Specify a Maven coordinate. See [Maven or Spark package](https://docs.databricks.com/aws/en/libraries/package-repositories.md#maven-libraries).                                                                                                                  |
   | **CRAN**              | Enter the name of a package. See [CRAN package](https://docs.databricks.com/aws/en/libraries/package-repositories.md#cran-libraries).                                                                                                                            |
   | **DBFS** (Deprecated) | Load a JAR or Whl file to the DBFS root. This is deprecated and not a recommended pattern.                                                                                                                                                                       |

4. Click **Add**.

#### Effect of adding libraries to policies

If you add libraries to a policy:

* Users can't install or uninstall compute-scoped libraries on compute that use this policy.
* Libraries configured through the UI, REST API, or CLI on existing compute are removed the next time the compute restarts.
* Dependency libraries for tasks that use this policy in jobs compute resources are disabled.

## Policy permissions

By default, workspace admins have permissions on all policies. Non-admin users must be granted permissions on a policy to access it.

If a user has unrestricted cluster creation permissions, then they will also have access to the **Unrestricted** policy. This allows them to create fully configurable compute resources.

If a user doesn't have access to any policies, the policy dropdown does not display in their UI.

### <a id="cluster-limit" />Restrict the number of compute resources per users

Policy permissions allow you to set a max number of compute resources per user. This determines how many resources a user can create using that policy. If the user exceeds the limit, the operation fails.

To restrict the number of resources a user can create using a policy, enter a value into the **Max compute resources per user** setting under **Advanced options**.

> [!NOTE]
>
> Databricks doesn't proactively terminate resources to maintain the limit. If a user has three compute resources running with the policy and the workspace admin reduces the limit to one, the three resources will continue to run. Extra resources must be manually terminated to comply with the limit.

## <a id="manage-policy" />Manage a policy

After you create a policy, you can edit, clone, and delete it.

You can also monitor the policy's adoption by viewing the compute resources that use the policy. From the **Policies** page, click the policy you want to view. Then click the **Compute** or **Jobs** tabs to see a list of resources that use the policy.

### Edit a policy

You might want to edit a policy to update its permissions or its definitions. To edit a policy, select the policy from the Policies page then click **Edit**.

After you update a policy's definitions, the compute resources created using that policy aren't automatically updated with the new policy definitions. You can choose to update all or some of these compute resources using policy compliance enforcement. See [Enforce policy compliance](https://docs.databricks.com/aws/en/admin/clusters/policies.md#compliance).

### Clone a policy

You can also use the cloning feature to create a new policy from an existing policy. Open the policy you want to clone then click the ![Kebab menu icon.](https://docs.databricks.com/aws/en/images/product-icons/OverflowIcon.svg) kebab menu and select **Clone** button. Then change any values of the fields that you want to modify and click **Create**.

### Delete a policy

Select the policy from the Policies page then click the ![Kebab menu icon.](https://docs.databricks.com/aws/en/images/product-icons/OverflowIcon.svg) kebab menu and select **Delete**. When asked if you're sure you want to delete the policy, click **Delete** again.

Any compute governed by a deleted policy can still run, but it cannot be edited unless the user has unrestricted cluster creation permissions.

## <a id="compliance" />Enforce policy compliance

After you edit a policy, the compute resources created using that policy do not automatically update to adhere to the new policy rules. To view a list of compute resources governed by the policy, click the policy in the UI to view the all-purpose compute and jobs that use the policy.

These lists will also tell you if any compute resources are out of compliance with the current policy definitions.

![Policy compliance shared compute UI](https://docs.databricks.com/aws/en/images/administration-guide/policy-compliance.png)

To update compute resources to comply with a policy:

1. From the **Policies** page, click the policy you have updated.

2. View the **All-purpose** or **Jobs** sections to see a list of resources or jobs that use the policy. The **Compliance** column tells you which resources are in compliance with the current policy definitions.

3. Click **Enforce all** to update all compute resources in the list that are out of compliance. You can also individually update compute resources by clicking the **Enforce** button in the resource's row.

4. For all-purpose compute, choose how to apply the updates:

   * **Enforce on next restart** (default): Schedules the configuration update to apply the next time the compute terminates or restarts. Running workloads aren't interrupted. Only workspace admins can schedule or cancel deferred enforcement.
   * **Restart and enforce**: Immediately restarts the compute and applies the updated configuration.

   Jobs compute is always enforced immediately, because enforcement doesn't require running job runs to terminate.

5. Click **Enforce** to make the updates. After the enforcement operation is completed you are given a summary of the changes made.

6. Click **Done**.

> [!NOTE]
>
> When you enforce policy compliance, array-type attributes such as init scripts are matched by index position. If a policy defines a value at a given position, the existing value at that position is replaced. The replaced value is not moved to another position in the array. To preview the changes before enforcing, click **Enforce** next to an individual resource to see how its attributes will be updated.

### <a id="scan-compliance" />Scan resources for compliance

> [!NOTE]
>
> The compliance scan is rolling out gradually and might not appear in every workspace.

A compliance scan checks every classic all-purpose and jobs compute resources under a policy and reports which resources are out of compliance. For each resource, the compliance scan shows the policy rules the resource violates, the resource owner, and whether enforcement can bring it into compliance or the owner must edit it manually. Use a scan to review an entire policy at once, rather than checking the **Compliance** column for each resource.

To scan the resources under a policy:

1. From the **Policies** page, click the policy you want to check.
2. On the **Overview** tab, in the **Enforcement** section, click **Scan all resources for compliance**.
3. In the **Compliance scan results** dialog, wait for the scan to finish. To stop a running scan, click **Cancel**.

The dialog lists only out-of-compliance resources. Each row shows the resource **Type**, **Owner**, the **Out-of-compliance rules** the resource violates, and a **Status**. To see a rule's current value and the value that enforcement applies, hover over the rule.

A resource has one of the following statuses:

* **Auto-fixable**: Enforcement can bring the resource into compliance without a manual edit. If enforcement doesn't fix it, edit the resource manually.
* **Manual edit required**: Enforcement can't bring the resource into compliance. The owner must edit it manually.
* **Enforce scheduled**: A deferred enforcement is scheduled to apply on the resource's next restart. If a scheduled enforcement is more than seven days overdue, the status is **Enforce scheduled, stale**.
* **Could not determine**: The scan couldn't check the resource. Run the scan again to recheck it.

To fix a resource, click **Edit** to open the resource in a new browser tab, then update its configuration or enforce compliance. To narrow the list of compute resources, filter by **Owner** or **Status**.

### Cancel a scheduled enforcement

Workspace admins can cancel pending deferred enforcements on all-purpose compute:

* To cancel all pending enforcements for a policy, click **Cancel all enforcements** on the policy details page.
* To cancel the pending enforcement for a single compute resource, open the ![Kebab menu icon.](https://docs.databricks.com/aws/en/images/product-icons/OverflowIcon.svg) kebab menu on that compute resource and select **Cancel pending enforcement**.

When a deferred enforcement is scheduled on a compute resource, the compute details page includes an **Update scheduled on next restart** label. Workspace admins can cancel the pending enforcement from this page by clicking the kebab menu ![Kebab menu icon.](https://docs.databricks.com/aws/en/images/product-icons/OverflowIcon.svg) and then selecting **Cancel pending enforcement**.

### Enforce compliance from the compute details page

Out-of-compliance all-purpose compute resources include an **Out of compliance** label in their compute details UI. Users with CAN MANAGE permissions on the compute resource can schedule enforcement from this page by clicking the kebab menu ![Kebab menu icon.](https://docs.databricks.com/aws/en/images/product-icons/OverflowIcon.svg) and then selecting **Fix compliance**.

![Policy compliance out of compliance UI](https://docs.databricks.com/aws/en/images/administration-guide/out-of-compliance.png)

## Add compute to a policy

> [!NOTE]
>
> You must be a workspace admin to add compute to a policy.

You can apply a policy to many existing all-purpose compute resources at once from the policy's details page. Using this feature assigns the policy to each selected compute resource and updates each compute's configuration to comply with the policy.

To add compute to a policy, click the ![Kebab menu icon.](https://docs.databricks.com/aws/en/images/product-icons/OverflowIcon.svg) kebab menu, then select **Add compute to policy**.

![Add compute to policy buttons on a policy detail page](https://docs.databricks.com/aws/en/images/administration-guide/add-compute-to-policy.png)

This opens the **Add compute to policy** modal, which guides you through three steps.

### Select compute

Select the all-purpose compute resources to add to the policy. The list supports search, filtering, and pagination, and your selection is kept as you page and filter. You can only select a compute resource if it is in a **Running** or **Terminated** state and does not already use a policy.

Select at least one compute resource, then click **Preview changes**.

![Modal shows compute to select to add to the policy](https://docs.databricks.com/aws/en/images/administration-guide/add-compute-to-policy-select.png)

### Preview changes

The **Preview** step summarizes the changes before anything is applied:

* **Compute selected** and **Will be updated** show how many compute resources you selected and how many will change. If any previews fail, **Couldn't be previewed** shows how many.
* **Fields that will change** lists each configuration field that will change, its new value, and the affected compute resources. If no changes are needed, the step shows **No configuration changes**.

![Modal previews changes that will be made to the compute](https://docs.databricks.com/aws/en/images/administration-guide/add-compute-to-policy-preview.png)

> [!WARNING]
>
> If you select any running compute, applying the policy restarts the compute so the policy can take effect. The **Preview** step warns you how many running compute resources will be restarted. There is no option to skip the restart.

To continue, click **Apply policy**. To change your selection, click **Back**.

### Apply the policy

The **Apply** step applies the policy to each selected compute resource and shows a progress bar. When it finishes, a summary reports how many compute resources were **Selected**, **Attempted**, **Succeeded**, and **Failed**.

If all compute resources update successfully, the step shows a **Policy applied** confirmation. If any fail, a **Failures** section lists the affected compute and groups the errors by reason, such as an edit conflict when a compute resource was modified during the operation, or insufficient permissions.

Click **Done** to close the modal.
