首页 > 解决方案 > 使用 aws cli 创建资源时如何使用标签选项?

问题描述

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

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

我无法解析文档

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

标签: amazon-web-servicestagsaws-cli

解决方案


我们需要传递两个属性

  • 资源类型:在这种情况下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}]'
    

推荐阅读