CLI de secretos (heredado)

Importante

Esta documentación se ha retirado y es posible que no se actualice.

Esta información se aplica a las versiones heredadas de la CLI de Databricks 0.18 y versiones posteriores. En su lugar, Databricks recomienda usar la versión más reciente 0.205 o posterior de la CLI de Databricks. Consulte ¿Qué es la CLI de Databricks?. Para encontrar su versión de la CLI de Databricks, ejecute databricks -v.

Para migrar de la versión 0.18 o inferior a la versión 0.205 o superior de la CLI de Databricks, consulte Migración de la CLI de Databricks.

Para ejecutar subcomandos de la CLI de secretos de Databricks, anéxelos a databricks secrets. Estos subcomandos llaman a la API de secretos.

Para más información sobre los secretos, vea Administración de secretos.

Nota:

La CLI de secretos requiere la CLI de Databricks 0.7.1 o posterior.

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.
      --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.
  write         Puts a secret in a scope. "write" is an alias for "put".
    Options:
      --scope SCOPE                  The name of the secret scope.
      --key KEY                      The name of the secret key.
      --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.
  write-acl     Creates or overwrites an access control rule for a principal
                applied to a given secret scope. "write-acl" is an alias for
                "put-acl".
    Options:
      --scope SCOPE                    The name of the secret scope.
      --principal PRINCIPAL            The name of the principal.
      --permission [MANAGE|WRITE|READ] The permission to apply.

Creación de un ámbito de secretos

Para mostrar la documentación de uso, ejecute databricks secrets create-scope --help.

databricks secrets create-scope --scope my-scope

Si se ejecuta correctamente, no se muestra ninguna salida.

Para usar la CLI de Databricks para crear un ámbito de secretos con respaldo de Azure Key Vault, ejecute databricks secrets create-scope --help para mostrar información sobre las opciones adicionales --scope-backend-type, --resource-idy --dns-name. Para más información, vea Secretos.

eliminar un secreto

Para mostrar la documentación de uso, ejecute databricks secrets delete --help.

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

Si se ejecuta correctamente, no se muestra ninguna salida.

Revocación de una ACL de una entidad de seguridad

Para mostrar la documentación de uso, ejecute databricks secrets delete-acl --help.

databricks secrets delete-acl --scope my-scope --principal someone@example.com

Si se ejecuta correctamente, no se muestra ninguna salida.

Eliminar un ámbito de secreto

Para mostrar la documentación de uso, ejecute databricks secrets delete-scope --help.

databricks secrets delete-scope --scope my-scope

Si se ejecuta correctamente, no se muestra ninguna salida.

Obtención de una ACL de una entidad de seguridad

Para mostrar la documentación de uso, ejecute databricks secrets get-acl --help.

databricks secrets get-acl --scope my-scope --principal someone@example.com --output JSON
{
  "principal": "sonmeone@example.com",
  "permission": "MANAGE"
}

Enumeración de las claves secretas almacenadas dentro de un ámbito de secretos

Para mostrar la documentación de uso, ejecute databricks secrets list --help.

databricks secrets list --scope my-scope --output JSON
{
  "secrets": [
    {
      "key": "my-key",
      "last_updated_timestamp": 1621284092605
    }
  ]
}

Nota:

No se puede acceder a los valores secretos mediante la CLI de Databricks. Para acceder a los valores secretos, debe usar la utilidad secrets de Utilidades de Databricks en un cuaderno de Databricks.

Enumeración de las ACL de un ámbito de secretos

Para mostrar la documentación de uso, ejecute databricks secrets list-acls --help.

databricks secrets list-acls --scope my-scope --output JSON
{
  "items": [
    {
      "principal": "someone@example.com",
      "permission": "MANAGE"
    }
  ]
}

Enumeración de todos los ámbitos de secretos disponibles en el área de trabajo

Para mostrar la documentación de uso, ejecute databricks secrets list-scopes --help.

databricks secrets list-scopes --output JSON
{
  "scopes": [
    {
      "name": "my-scope",
      "backend_type": "DATABRICKS"
    }
  ]
}

Crear o actualizar un secreto

Para mostrar la documentación de uso, ejecute databricks secrets put --help o databricks secrets write --help.

Hay tres maneras de almacenar un secreto. La manera más fácil es usar la opción --string-value; el secreto se almacena en formato UTF-8 (MB4). Debe tener cuidado con esta opción, ya que el secreto puede almacenarse en el historial de la línea de comandos en texto sin formato.

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

O:

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

Si se ejecuta correctamente, no se muestra ninguna salida.

También puede usar la opción --binary-file para proporcionar un secreto almacenado en un archivo. El contenido del archivo se lee tal cual y se almacena como bytes.

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

O:

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

Si se ejecuta correctamente, no se muestra ninguna salida.

Si no especifica una opción, se abre un editor para que escriba el secreto. Siga las instrucciones que se muestran en el editor para escribir el secreto.

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

O:

databricks secrets write --scope my-scope --key my-key

# ----------------------------------------------------------------------
# Do not edit the above line. Everything below it will be ignored.
# Please input your secret value above the line. Text will be stored in
# UTF-8 (MB4) form and any trailing new line will be stripped.
# Exit without saving will abort writing secret.

Concesión de una ACL a un ámbito de secretos de una entidad de seguridad o cambio

Para mostrar la documentación de uso, ejecute databricks secrets put-acl --help o databricks secrets write-acl --help.

databricks secrets put-acl --scope my-scope --principal someone@example.com --permission MANAGE

O:

databricks secrets write-acl --scope my-scope --principal someone@example.com --permission MANAGE

Si se ejecuta correctamente, no se muestra ninguna salida.