使用 aws cli 创建资源时如何使用标签选项?

时间:2021-01-23 00:06:10

标签: amazon-web-services tags aws-cli

尝试使用 aws cli 创建标记项。

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

我无法解析 documentation

--tag-specifications (list)

我试过

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

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

1 个答案:

答案 0 :(得分:1)

我们需要传递两个属性

  • ResourceType:在本例中为 security-group

  • 标签:键值对象数组

    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}]'