-1

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?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Chintamani
  • 1,076
  • 7
  • 23
  • 47

3 Answers3

0

You have a space here between the -- and tags:

-- tags {"env":"dev","sample=test"} \

It should be:

--tags {"env":"dev","sample=test"} \

Also, you're syntax is totally wrong for setting tags. You're using : in the first tag, and = in the 2nd tag, but your overall syntax is wrong anyway. I suggest looking at the documentation and copying their examples.

It should be:

--tags [{"Key":"env","Value":"dev"},{"Key":"sample","Value":"test"}] \
Mark B
  • 183,023
  • 24
  • 297
  • 295
  • Thank you Mark ,but still getting error Error parsing parameter '--tags': Expected: '=', received: 'EOF' for input: env:dev – Chintamani Feb 27 '22 at 15:31
  • @Chintamani see my updated answer – Mark B Feb 27 '22 at 15:35
  • Hi Mark ,I tried this ,but getting invalid json .My command is aws secretsmanager create-secret \ --name sample_auth_aws_secret1 \ --description "My test secret created with the CLI." \ --tags [{"Key":"env","Value":"dev"},{"Key":"sample","Value":"test"}] \ --secret-string "{\"clientId\":\"sample123\",\"secret\":\"wjwjwjwjwjwjwjsjsjsj\"}" .getting Error parsing parameter '--tags': Invalid JSON: [Key:env,Key:sample] – Chintamani Feb 27 '22 at 15:42
0

It has to do with the tags that you are passing. You need a proper Key and Value assignment.

Try passing the working shorthand:

--tags Key="env",Value="dev" Key="sample",Value="test" \

craig
  • 3
  • 4
0

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\"}"
Anurag Arya
  • 111
  • 4