Share via


CLI de segredos (herdada)

Importante

Esta documentação foi desativada e pode não estar atualizada.

Essas informações se aplicam às versões herdadas da CLI do Databricks 0.18 e anteriores. O Databricks recomenda que você use a versão 0.205 da CLI do Databricks mais recente ou superior. Consulte O que é a CLI do Databricks?. Para localizar sua versão da CLI do Databricks, execute databricks -v.

Para migrar da CLI do Databricks versão 0.18 ou inferior para a versão 0.205 ou superior, consulte Migração da CLI do Databricks.

Execute segredos da CLI de pilha do Databricks acrescentando-os ao databricks secrets. Esses subcomandos chamam a API de Segredos.

Para obter mais informações sobre segredos, confira Gestão de segredos.

Observação

A CLI de segredos exige a CLI 0.7.1 ou superior do Databricks.

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.

Criar um escopo secreto

Para exibir a documentação de uso, execute databricks secrets create-scope --help.

databricks secrets create-scope --scope my-scope

Se obtiver sucesso, nenhuma saída será exibida.

Para usar a CLI do Databricks para criar um escopo de segredo com backup do Azure Key Vault, execute databricks secrets create-scope --help para exibir informações sobre as opções --scope-backend-type, --resource-id e --dns-name adicionais. Para saber mais, consulte Segredos.

Excluir um segredo

Para exibir a documentação de uso, execute databricks secrets delete --help.

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

Se obtiver sucesso, nenhuma saída será exibida.

Revogar uma ACL para uma entidade de segurança

Para exibir a documentação de uso, execute databricks secrets delete-acl --help.

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

Se obtiver sucesso, nenhuma saída será exibida.

Excluir um escopo de segredo

Para exibir a documentação de uso, execute databricks secrets delete-scope --help.

databricks secrets delete-scope --scope my-scope

Se obtiver sucesso, nenhuma saída será exibida.

Obter uma ACL para uma entidade de segurança

Para exibir a documentação de uso, execute databricks secrets get-acl --help.

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

Listar as chaves secretas armazenadas em um escopo secreto

Para ver a documentação de uso, execute databricks secrets list --help.

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

Observação

Você não pode acessar valores secretos usando a CLI do Databricks. Para acessar valores secretos, você deve usar o Utilitário de segredos do Databricks em um notebook do Databricks.

Listar as ACLs para um escopo secreto

Para exibir a documentação de uso, execute databricks secrets list-acls --help.

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

Listar todos os escopos de segredo disponíveis no workspace

Para exibir a documentação de uso, execute databricks secrets list-scopes --help.

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

Criar ou atualizar um segredo

Para exibir a documentação de uso, execute databricks secrets put --help ou databricks secrets write --help.

Há três maneiras de armazenar um segredo. A maneira mais fácil é usar a opção --string-value; o segredo será armazenado no formato UTF-8 (MB4). Você deve ter cuidado com essa opção, pois seu segredo pode ser armazenado em seu histórico da linha de comando em texto sem formatação.

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

Ou:

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

Se obtiver sucesso, nenhuma saída será exibida.

Você também pode usar a opção --binary-file para fornecer um segredo armazenado em um arquivo. O conteúdo do arquivo será lido no estado em que se encontra e armazenado como bytes.

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

Ou:

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

Se obtiver sucesso, nenhuma saída será exibida.

Se você não especificar uma opção, um editor será aberto para que você insira seu segredo. Siga as instruções exibidas no editor para inserir seu segredo.

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

Ou:

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.

Conceder ou alterar uma ACL para um escopo secreto para uma entidade de segurança

Para exibir a documentação de uso, execute databricks secrets put-acl --help ou databricks secrets write-acl --help.

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

Ou:

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

Se obtiver sucesso, nenhuma saída será exibida.