Skip to main content

Google Cloud Secret Manager secrets in Unity Catalog

Beta

This feature is in Beta.

Back a Unity Catalog schema with Google Cloud Secret Manager to use your secrets in notebooks, jobs, and UDFs without copying them. The values stay in Google Cloud Secret Manager, and Unity Catalog privileges control who can read or use each secret.

To compare external secrets with Databricks-managed secrets and workspace secret scopes, see Choose where to store a secret.

How external secrets work​

A schema is backed by one connection to your cloud secret manager. Two independent controls decide who can use a secret. The service credential's permissions in your secret manager decide which secrets Unity Catalog can import and read, and Unity Catalog privileges decide which principals can use them.

The service account's Identity and Access Management (IAM) roles and each connection's label filter decide which Secret Manager secrets each schema imports. UC privileges decide who can use them.

After you back a schema, external secrets behave as follows:

  • Each read fetches the current value: A value you rotate in your secret manager takes effect on the next read, with no change in Databricks. Code that already holds a value keeps it until it reads the secret again. Retrieved values may be cached on the compute that requested them, as with other secrets.
  • Manage secrets in your secret manager: Create, update, rotate, and delete secrets there. They are read-only in Unity Catalog. When you permanently delete a secret in your secret manager, Databricks removes the Unity Catalog secret, including its permissions and tags.
  • Listing imports new secrets: Listing the schema starts an asynchronous import. A secret added to or removed from your secret manager appears in Unity Catalog after a later list, which can take a few minutes for large stores. You can read a secret by name before it appears in a list.
  • Audit logs record both sides: Unity Catalog audit logs record the Databricks principal that read a secret. Cloud-side logs attribute access to the service credential.

Requirements​

  • Meet the requirements for Unity Catalog secrets.
  • The external secrets Beta must be enabled for your workspace. See Manage Databricks previews.
  • You need a Unity Catalog service credential and a Unity Catalog connection that uses it to authenticate to your secret manager. See Create service credentials and Create a connection.
  • To back the schema, you need USE CATALOG on the catalog, ownership of the schema or MANAGE on it, and USE CONNECTION on the connection. The schema must not contain any Databricks-managed secrets, so delete any before you back it.

Set up external secrets​

Create a service credential​

The connection authenticates to your secret manager with a Unity Catalog service credential.

  1. Enable the Secret Manager API in the project that contains the secrets.
  2. Create a service credential. Databricks generates a service account. Copy its service account ID, which is an email address.
  3. In the project that contains the secrets, grant the generated service account these IAM roles:
    • Secret Manager Viewer (roles/secretmanager.viewer): Grant this role on the project so Databricks can list secrets and read their metadata.
    • Secret Manager Secret Accessor (roles/secretmanager.secretAccessor): Grant this role on the project or on each secret whose value Databricks can read.

See Secret Manager roles and permissions in the Google Cloud documentation. If you grant the accessor role on only selected secrets, use a connection label filter to prevent the other secrets from appearing in Unity Catalog.

Create a connection​

Create a Unity Catalog connection that uses the service credential and points to your secret manager. You need CREATE CONNECTION on the metastore.

  1. In Catalog Explorer, click the + menu and select Create a connection.
  2. Enter a Connection name and select the Google Cloud Secret Manager connection type.
  3. Select the service credential, and enter the Project ID of the project that contains the secrets.
  4. For Secret Manager scope, select Global, or select Regional and enter the secret location, such as us-central1.
  5. Optionally, enter a Label key and a Label value. See Filter imported secrets by label.
  6. Click Create.

Back a schema with the connection​

  1. In Catalog Explorer, go to the schema.
  2. In the schema's details, find the external secrets manager setting and click Enable. Enable stays unavailable until the schema has no secrets.
  3. Select the connection you created, then confirm.

To point the schema at a different connection, click Edit. To return the schema to Databricks-managed storage, edit the schema and disable external secrets. Either change removes the previously imported secrets from the schema, including their permissions and tags.

Verify the setup​

To confirm that Unity Catalog can list and read your secrets, run the following in a notebook:

Python
# List the secrets in the schema. This also starts an import of new secrets.
dbutils.secrets.list(catalog="main", schema="orders_app")

# Read one secret by name
dbutils.secrets.get(catalog="main", schema="orders_app", key="example_secret")

If the list is empty, run it again after a few minutes. If a read fails, see Troubleshooting.

Filter imported secrets by label​

To surface only some secrets that the connection can access, set a label filter when you create or edit the connection:

  • label_key: Surface only secrets that carry this label key. Keys must contain 1 to 63 lowercase ASCII letters, digits, underscores, or hyphens, and must start with a letter.
  • label_value: Surface only secrets whose label matches this value. This option requires label_key. Values must contain 1 to 63 lowercase ASCII letters, digits, underscores, or hyphens. An empty value is not supported. If you omit this option, Unity Catalog surfaces every secret with label_key, regardless of value.

Label matching is case-sensitive and uses exact string equality. The connection filter controls which secrets Unity Catalog surfaces. Use IAM to control which values the service credential can read.

Secret names in Unity Catalog​

Unity Catalog imports an external secret only if its name meets these rules:

  • Names longer than 255 characters are not imported.
  • Names are case-insensitive. If two secrets differ only by case, Unity Catalog keeps the first one imported and ignores the rest.

Troubleshooting​

  • A secret is listed, but reading it fails: The service account does not have the Secret Manager Secret Accessor role for that secret, or its latest version is disabled or destroyed. Grant access or add an enabled version.
  • A secret is not found when you read it by name: The secret is outside the connection's label filter, project, or global or regional scope. Check the connection options and the Secret Manager Viewer role.
  • A new secret doesn't appear: List the schema, wait a few minutes, and list it again. Check the naming restrictions and the schema quota.
  • Some secrets never appear: A schema holds up to 1,000 secrets. When your secret manager has more, Unity Catalog imports the oldest first by creation date and skips the rest. Expose only the secrets you need in each schema. See Group secrets by who needs them.

Limitations​

In addition to the limitations that apply to all Unity Catalog secrets, externally backed secrets have the following limitations:

  • Cross-cloud access is not supported: Back schemas with the secret manager native to the workspace's cloud.
  • Read latency and cost: Every read fetches the value from the external secret manager, which adds latency and can incur cloud provider costs.
  • Global or regional scope: A Google Cloud Secret Manager connection targets either global secrets or regional secrets in one location. Create separate connections and schemas for different scopes or locations.
  • Latest version reads: Databricks reads the latest secret version. If that version is disabled or destroyed, the secret can still appear in Unity Catalog, but reading its value fails.
  • UTF-8 values only: Databricks rejects secret values that are not valid UTF-8.
note

If the external secret manager that backs a schema is in a different region from the metastore or workspace that reads it, secret values and their metadata cross regions. Databricks does not guarantee in-region processing of external secrets.

External secret names and values can contain personal data. You are responsible for keeping personal data out of them unless your use case requires it.

Additional resources​