CLI的秘密

请注意

Secrets CLI需要Databricks CLI 0.7.1及以上版本。

可以通过将Databricks secrets CLI子命令附加到秘密.这些子命令调用秘密API 2.0

有关秘密的更多信息,请参见保密管理

数据秘密——帮助
用法:databricks secrets [OPTIONS] COMMAND [ARGS]…与秘密API交互的实用程序。选项:-v,——version [version]——profile TEXT要使用的CLI连接配置文件。默认配置文件为default。-h,——help显示此消息并退出。命令:create-scope创建秘密作用域。选项:——scope scope秘密作用域的名称。——initial-manage-principal可以管理创建的secret作用域的初始主体。如果指定了,则将应用到范围的具有MANAGE权限的初始ACL分配给提供的主体(用户或组)。唯一受支持的主体是组“users”,它包含工作区中的所有用户。 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.

创建秘密作用域

要显示使用文档,请运行秘密创建范围——帮助

数据库机密创建-scope——scope my-scope

如果成功,则无输出。

删除秘密

要显示使用文档,请运行秘密删除——帮助

数据库机密删除——scope my-scope——key my-key

如果成功,则无输出。

撤销主体的ACL

要显示使用文档,请运行秘密delete-acl——帮助

删除-acl——scope my-scope——principal someone@example.com

如果成功,则无输出。

删除秘密作用域

要显示使用文档,请运行秘密delete-scope——帮助

删除数据库机密——scope my-scope

如果成功,则无输出。

获取主体的ACL

要显示使用文档,请运行秘密get-acl——帮助

databricks secrets get-acl——scope my-scope——principal someone@example.com——输出JSON
“主要”:“sonmeone@example.com”,“许可”:“管理”

列出存储在秘密作用域中的秘密密钥

要显示使用文档,请运行秘密列表——帮助

databricks秘密列表——scope my-scope——输出JSON
“秘密”:(“关键”:“我的钥匙”,“last_updated_timestamp”:1621284092605

请注意

不能通过Databricks命令行访问机密值。要访问秘密值,必须使用Databricks实用程序秘密的效用在一个数据库笔记本里。

列出一个秘密作用域的acl

要显示使用文档,请运行秘密list-acls——帮助

databricks secrets list-acls——scope my-scope——输出JSON
“物品”:(“主要”:“someone@example.com”,“许可”:“管理”

列出工作区中所有可用的秘密作用域

要显示使用文档,请运行秘密list-scopes——帮助

databricks secrets list-scopes—输出JSON
“范围”:[“名称”:“我的领域”,“backend_type”:“砖”

创建或更新秘密

要显示使用文档,请运行秘密——帮助秘密——帮助

有三种方法来保存秘密。最简单的方法是使用——字符串值选择;该秘密将以UTF-8 (MB4)格式存储。您应该小心使用这个选项,因为您的秘密可能以纯文本的形式存储在命令行历史记录中。

数据库机密put——scope my-scope——key my-key——string-value my-value

或者:

数据库秘密写——范围my-范围——键my-键——字符串值my-值

如果成功,则无输出。

你也可以使用——二进制文件选项,提供存储在文件中的秘密。文件内容将按原样读取,并以字节的形式存储。

数据库机密设置——scope my-scope——key my-key——二进制文件my-secret.txt

或者:

数据库机密写入——scope my-scope——key my-key——二进制文件my-secret.txt

如果成功,则无输出。

如果您没有指定一个选项,将打开一个编辑器供您输入您的秘密。按照编辑器中显示的说明输入您的秘密。

数据机密放,范围我的范围,钥匙我的钥匙

或者:

数据库机密写——范围我的范围——密钥我的密钥
----------------------------------------------------------------------不要编辑上面的行。它下面的所有内容都将被忽略。请在该行上方输入您的秘密值。文本将被存储utf - 8MB4表单和任何尾随的新行将被剥离。不保存退出将中止写入秘密。

将ACL授予或更改为主体的秘密范围

要显示使用文档,请运行秘密put-acl——帮助秘密write-acl——帮助

数据库秘密——放置acl——scope my-scope——principal someone@example.com——权限管理

或者:

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

如果成功,则无输出。