---
title: Secret management
description: Compare workspace secret scopes with Unity Catalog secrets, including AWS Secrets Manager secrets, and see where you can use each.
canonical_url: https://docs.databricks.com/aws/en/security/secrets/
---

# Secret management

A Databricks secret stores a sensitive value, such as a password, API key, or hashing salt, so that notebooks, jobs, and functions can use it without the value appearing in code. You can manage secrets in two places:

* **Workspace secret scopes**: Named collections of secrets in one workspace. Permissions apply to the whole scope. See [Workspace secret scopes](https://docs.databricks.com/aws/en/security/secrets/workspace-secret-scopes.md).
* **Secrets in Unity Catalog**: Securable objects (`catalog.schema.secret`) that are available in every workspace attached to the metastore. You can grant access to each secret. See [Secrets in Unity Catalog](https://docs.databricks.com/aws/en/security/secrets/unity-catalog-secrets.md).

Unity Catalog secrets can be Databricks-managed or backed by AWS Secrets Manager. See [AWS Secrets Manager secrets in Unity Catalog](https://docs.databricks.com/aws/en/security/secrets/external-secrets.md).

## <a id="choose-where-to-store-a-secret" /><a id="choose-where-to-manage-a-secret" />Choose where to store a secret

The following table compares where each option stores secret values, which workspaces can use them, and how you control access.

|                              | Workspace secret scope                                                                                                                              | Databricks-managed secret in Unity Catalog                                                                                                                               | AWS Secrets Manager-backed secret in Unity Catalog (Beta)                                                                                                                |
| ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Where the value is stored    | Databricks, in the workspace                                                                                                                        | Databricks, in Unity Catalog                                                                                                                                             | AWS Secrets Manager (Databricks stores only the secret name in Unity Catalog)                                                                                            |
| Encryption with your own key | Yes, with a [customer-managed key for managed services](https://docs.databricks.com/aws/en/security/keys/customer-managed-keys.md#managed-services) | Yes, with a [customer-managed key on the catalog](https://docs.databricks.com/aws/en/security/keys/cmek-unity-catalog.md)                                                | -                                                                                                                                                                        |
| Available in                 | One workspace                                                                                                                                       | Every workspace attached to the metastore                                                                                                                                | Every workspace attached to the metastore                                                                                                                                |
| Access control               | [Secret scope permissions](https://docs.databricks.com/aws/en/security/auth/access-control/index.md#secrets) (no secret-level access control)       | [Unity Catalog privileges](https://docs.databricks.com/aws/en/security/secrets/unity-catalog-secrets.md#manage-permissions-on-secrets) on the secret, schema, or catalog | [Unity Catalog privileges](https://docs.databricks.com/aws/en/security/secrets/unity-catalog-secrets.md#manage-permissions-on-secrets) on the secret, schema, or catalog |
| To rotate                    | Update the value in Databricks                                                                                                                      | Update the value in Databricks                                                                                                                                           | Rotate in AWS Secrets Manager. No change in Databricks.                                                                                                                  |

## <a id="where-you-can-use-secrets" />Where you can use secrets

Workspace secret scopes and Unity Catalog secrets are supported in different places. Before you choose one, check that it works where your code runs.

| Surface                                                             | Workspace secret scope                                                                                                                                                                                                       | Secret in Unity Catalog                                                                                                                                                                                       |
| ------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `dbutils.secrets` in notebooks and jobs                             | Yes. See [Read a secret](https://docs.databricks.com/aws/en/security/secrets/workspace-secret-scopes.md#read-a-secret).                                                                                                      | Yes, on serverless environment version 4 and above or Databricks Runtime 17.3 LTS and above. See [Read a secret](https://docs.databricks.com/aws/en/security/secrets/unity-catalog-secrets.md#read-a-secret). |
| REST API and Databricks CLI                                         | Yes. Values returned by the API aren't redacted.                                                                                                                                                                             | Yes. Values returned by the API aren't redacted.                                                                                                                                                              |
| Remote development, such as Databricks Connect                      | Yes, with `dbutils.secrets` in the Databricks Connect client. See [Databricks Utilities with Databricks Connect for Python](https://docs.databricks.com/aws/en/dev-tools/databricks-connect/python/databricks-utilities.md). | No                                                                                                                                                                                                            |
| Unity Catalog Python and Scala UDFs                                 | No                                                                                                                                                                                                                           | Yes. Callers need only `EXECUTE`. See [Use secrets in UDFs](https://docs.databricks.com/aws/en/security/secrets/unity-catalog-secrets.md#udf-secret-requirements).                                            |
| SQL warehouses                                                      | Yes, with the [secret function](https://docs.databricks.com/aws/en/sql/language-manual/functions/secret.md)                                                                                                                  | Only through a Unity Catalog Python or Scala UDF that declares the secret                                                                                                                                     |
| Spark configuration properties and environment variables on compute | Yes. See [Use a secret in a Spark configuration property or environment variable](https://docs.databricks.com/aws/en/security/secrets/secrets-spark-conf-env-var.md).                                                        | No                                                                                                                                                                                                            |
| Model serving endpoint environment variables                        | Yes. See [Add secrets-based environment variables](https://docs.databricks.com/aws/en/machine-learning/model-serving/store-env-variable-model-serving.md#secret-environment-variables).                                      | No                                                                                                                                                                                                            |
| Default package repositories                                        | Yes, in the `databricks-package-management` scope. See [Configure default package repositories](https://docs.databricks.com/aws/en/admin/workspace-settings/default-package-repositories.md).                                | No                                                                                                                                                                                                            |

## <a id="scopes" /><a id="manage-secret-scopes" /><a id="create-a-secret" /><a id="akv-ss" /><a id="databricks-backed" /><a id="list-scopes" /><a id="secrets" /><a id="key-vault-secret" /><a id="permissions" /><a id="redaction" />Additional resources

| Resource                                                                                                          | Description                                                                                                |
| ----------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| [Secrets in Unity Catalog](https://docs.databricks.com/aws/en/security/secrets/unity-catalog-secrets.md)          | Create Unity Catalog secrets, grant access, and read them in notebooks, jobs, and UDFs.                    |
| [Best practices for Unity Catalog secrets](https://docs.databricks.com/aws/en/security/secrets/best-practices.md) | Organize secrets by environment, application, or team, and let workloads use secrets without reading them. |
