13

How do I set a binary value on a secret in AWS Secrets Manager using the CLI?

The docs say:

--secret-binary (blob)

(Optional) Specifies binary data that you want to encrypt and store in the new version of the secret. To use this parameter in the command-line tools, we recommend that you store your binary data in a file and then use the appropriate technique for your tool to pass the contents of the file as a parameter.

I have tried the following:

$ 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
Rich
  • 704
  • 14
  • 30

2 Answers2

15

Found it:

aws secretsmanager put-secret-value --secret-id xxx --secret-binary fileb://mykeystore.jks
Rich
  • 704
  • 14
  • 30
7

The self-authored answer from OP covers how to set the value of an existing secret to a file binary. I wanted to add the way to use a file binary when creating an entirely new secret:

aws secretsmanager create-secret --name xxx --secret-binary fileb://mykeystore.jks
Abion47
  • 191
  • 1
  • 5