如何从 AWS Secrets Manager 的 CLI 设置二进制密钥值

Ric*_*ich 4 amazon-web-services aws-cli aws-secrets-manager

如何使用 CLI 在 AWS Secrets Manager 中为密钥设置二进制值?

文件说

--secret-binary (blob)

(可选)指定要加密并存储在新版本密钥中的二进制数据。要在命令行工具中使用此参数,我们建议您将二进制数据存储在文件中,然后使用适合您的工具的适当技术将文件内容作为参数传递。

我尝试了以下方法:

$ V=$(cat mykeystore.jks)
$ aws secretsmanager put-secret-value --secret-id xxx --secret-binary "$V"
'utf8' codec can't decode byte 0xfe in position 0: invalid start byte
Run Code Online (Sandbox Code Playgroud)

Ric*_*ich 7

找到了:

aws secretsmanager put-secret-value --secret-id xxx --secret-binary fileb://mykeystore.jks
Run Code Online (Sandbox Code Playgroud)


小智 7

OP 自己撰写的答案涵盖了如何将现有机密的值设置为文件二进制文件。我想添加在创建全新秘密时使用文件二进制文件的方法:

aws secretsmanager create-secret --name xxx --secret-binary fileb://mykeystore.jks
Run Code Online (Sandbox Code Playgroud)