Search code examples
amazon-web-servicesaws-cliaws-secrets-manager

Getting error while running create secrets manager command using aws cli


I am trying to create one secrets manager using aws cli command. The command I tried is

aws secretsmanager create-secret \
    --name sample_auth_aws_secret1 \
    --description "My test secret created with the CLI." \
    -- tags {"env":"dev","sample=test"} \
    --secret-string "{\"clientId\":\"sample123\",\"secret\":\"wjwjwjwjwjwjwjsjsjsj\"}"

I am getting error

usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help

Unknown options: env:dev, sample=test, --secret-string, {"clientId":"sample123","secret":"wjwjwjwjwjwjwjsjsjsj"}, tags

What did I do wrong?


Solution

  • There are two problems in your command.

    1. use --tags instead -- tags
    2. key value are not in correct json format.

    please use below command

    aws secretsmanager create-secret \
    --name sample_auth_aws_secret1 \
    --description "My test secret created with the CLI." \
    --tags '{"Key":"CostCenter","Value":"12345"}' \
    --secret-string "{\"clientId\":\"sample123\",\"secret\":\"wjwjwjwjwjwjwjsjsjsj\"}"