Secrets CLI

Note

The Secrets CLI requires Databricks CLI 0.7.1 or above.

You run Databricks secrets CLI subcommands by appending them to databricks secrets.

For more information about secrets, see Secret management.

databricks secrets --help
Usage: databricks secrets [OPTIONS] COMMAND [ARGS]...

  Utility to interact with secret API.

Options:
  -v, --version   [VERSION]
  --profile TEXT  CLI connection profile to use. The default profile is
                  "DEFAULT".
  -h, --help      Show this message and exit.

Commands:
  create-scope  Creates a secret scope.
    Options:
      --scope SCOPE                  The name of the secret scope.
      --initial-manage-principal     The initial principal that can manage the created secret scope.
                                      If specified, the initial ACL with MANAGE permission applied
                                      to the scope is assigned to the supplied principal (user or group).
                                      The only supported principal is the group
                                      "users", which contains all users in the workspace. If not
                                      specified, the initial ACL with MANAGE permission applied to
                                      the scope is assigned to request issuer's user identity.
  delete        Deletes a secret.
    Options:
      --scope SCOPE                  The name of the secret scope.
      --key KEY                      The name of secret key.
  delete-acl    Deletes an access control rule for a principal.
    Options:
      --scope SCOPE                  The name of the scope.
      --principal PRINCIPAL          The name of the principal.
  delete-scope  Deletes a secret scope.
    Options:
      --scope SCOPE                  The name of the secret scope.
  get-acl       Gets the details for an access control rule.
    Options:
      --scope SCOPE                  The name of the secret scope.
      --principal PRINCIPAL          The name of the principal.
      --output FORMAT                JSON or TABLE. Set to TABLE by default.
  list          Lists all the secrets in a scope.
    Options:
      --scope SCOPE                  The name of the secret scope.
      --output FORMAT                JSON or TABLE. Set to TABLE by default.
  list-acls     Lists all access control rules for a given secret scope.
    Options:
      --scope SCOPE                  The name of the secret scope.
      --output FORMAT                JSON or TABLE. Set to TABLE by default.
  list-scopes   Lists all secret scopes.
      --output FORMAT                JSON or TABLE. Set to TABLE by default.
  put           Puts a secret in a scope.
    Options:
      --scope SCOPE                  The name of the secret scope.
      --key KEY                      The name of the secret key.  [required]
      --string-value TEXT            Read value from string and stored in UTF-8 (MB4) form
      --binary-file PATH             Read value from binary-file and stored as bytes.
  put-acl       Creates or overwrites an access control rule for a principal
                applied to a given secret scope.
    Options:
      --scope SCOPE                    The name of the secret scope.
      --principal PRINCIPAL            The name of the principal.
      --permission [MANAGE|WRITE|READ] The permission to apply.

Create a secret scope

databricks secrets create-scope --scope my-scope

List all secret scopes in workspace

databricks secrets list-scopes

Delete a secret scope

databricks secrets delete-scope --scope my-scope

Create or update a secret in a secret scope

There are three ways to store a secret. The easiest way is to use the --string-value option; the secret will be stored in UTF-8 (MB4) form. You should be careful with this option, because your secret may be stored in your command line history in plain text.

databricks secrets put --scope my-scope --key my-key --string-value my-value

You can also use the --binary-file option to provide a secret stored in a file. The file content will be read as is and stored as bytes.

databricks secrets put --scope my-scope --key my-key --binary-file my-secret.txt

If you don’t specify any of the two options, an editor will be opened for you to enter your secret. Follow the instructions shown on the editor to enter your secret.

databricks secrets put --scope my-scope --key my-key

List secrets stored within the secret scope

databricks secrets list --scope my-scope

There is no interface to get secrets from the CLI. You must use the Databricks Utilities secret utilities interface within a Databricks notebook to access your secret.

Delete a secret in a secret scope

databricks secrets delete --scope my-scope --key my-key

Grant or change ACL for a principal

databricks secrets put-acl --scope my-scope --principal principal --permission MANAGE

List ACLs in a secret scope

databricks secrets list-acls --scope my-scope

Get ACL for a principal in a secret scope

databricks secrets get-acl --scope my-scope --principal principal

Revoke ACL for a principal

databricks secrets delete-acl --scope my-scope --principal principal