joar
joar

Reputation: 493

How does one use the tags option when creating resources with the aws cli?

Trying to create a tagged item with aws cli.

aws ec2 create-security-group --group-name $group_name --description $my_description

I can't parse the documentation

--tag-specifications (list)

I tried with

--tag-specifications KEY=Name,Value=$something

and --tags Key=Name,Value=$something
and --tags [Key=Name,Value=$something]
and --tags {[Key=Name,Value=$something]}

Upvotes: 5

Views: 1285

Answers (1)

Balu Vyamajala
Balu Vyamajala

Reputation: 10393

We need to pass two properties

  • ResourceType: in this case security-group

  • Tags: array of key-value object

    aws ec2 create-security-group --group-name 'test' --description 'test desc' --tag-specifications 'ResourceType=security-group,Tags=[{Key=purpose,Value=production},{Key=cost-center,Value=cc123}]'
    

Upvotes: 9

Related Questions