1

I am trying to store a new Secret in AWS Secrets Manager using AWS CLI.

On console i get an option to create a Other type of secrets under Select secret type where i choose a plaintext type under Specify the key/value pairs to be stored in this secret.

I want to do that using CLI. Below is the format to use the CLI Command

aws secretsmanager create-secret --name <value> [--client-request-token <value>] [--description <value>] [--kms-key-id <value>] [--secret-binary <value>] [--secret-string <value>] [--tags <value>] [--cli-input-json <value>] [--generate-cli-skeleton <value>] 
1
  • For 'Other type of secret', just create the secret normally with the cli command you have there. You won't see a behavior change in the console. Commented Nov 19, 2019 at 19:00

1 Answer 1

5

You can use the --secret-string option for this.

For Key-Value pairs you can do JSON formatted string and it will show up as Key-Value pairs in console:

aws secretsmanager create-secret --name my-secret-kv-pairs --secret-string '{"foo":"bar"}'

If you just want plain text you can do :

aws secretsmanager create-secret --name my-secret-just-text --secret-string 'My random string'

Sign up to request clarification or add additional context in comments.

2 Comments

That option works for a single key/value pair, but if I try to do one with multiple key value pairs, then it creates them as a JSON object? Is there another way to specify that multiple values are text and not JSON?
Nevermind I just figured it out. it has to do with the way you do the "{ }" This will yield the plaintext key/value pairs: { "username": "alice", "password": "abc123xyz456", "accessToken": "myAccessToken1" } Whereas this will yield only the JSON variant of the secret Value: {"username":"alice"},{"password":"abc123xyz456"},{"accessToken":"myAccessToken1"}

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.