Amazon web services AWS EC2:使用CLI启动实例时添加标记

Amazon web services AWS EC2:使用CLI启动实例时添加标记,amazon-web-services,amazon-ec2,aws-cli,Amazon Web Services,Amazon Ec2,Aws Cli,如果要在启动时向实例添加标记,则必须执行两个步骤: 启动实例(运行实例) 向新创建的实例添加标记(create tags) 使用单个CLI命令启动实例时,是否有方法添加标记(或设置名称)?此请求已挂起很长时间,AWS最终在2017年3月支持此请求 见: 确保您的AWS CLI版本至少为1.11.106 $ aws --version aws-cli/1.11.109 Python/2.6.9 Linux/4.1.17-22.30.amzn1.x86_64 botocore/1.5.72 C

如果要在启动时向实例添加标记,则必须执行两个步骤:

  • 启动实例(
    运行实例
  • 向新创建的实例添加标记(
    create tags

  • 使用单个CLI命令启动实例时,是否有方法添加标记(或设置名称)?

    此请求已挂起很长时间,AWS最终在2017年3月支持此请求

    见:


    确保您的AWS CLI版本至少为1.11.106

    $ aws --version
    aws-cli/1.11.109 Python/2.6.9 Linux/4.1.17-22.30.amzn1.x86_64 botocore/1.5.72
    

    CLI在启动时标记实例:

    下面的示例应用键为
    webserver
    和的标记 实例的
    production


    CLI来标记实例和卷:

    该命令还应用一个带有键
    成本中心
    和值的标记 对于创建的任何EBS卷(在本例中为根卷 体积)

    aws ec2 run-instances --image-id ami-abc12345 --count 1 --instance-type t2.micro 
        --key-name MyKeyPair --subnet-id subnet-6e7f829e
        --tag-specifications 'ResourceType=instance,Tags=[{Key=webserver,Value=production}]'
    
    aws ec2 run-instances --image-id ami-abc12345 --count 1 --instance-type t2.micro 
        --key-name MyKeyPair --subnet-id subnet-6e7f829e
        --tag-specifications 'ResourceType=instance,Tags=[{Key=webserver,Value=production}]' 'ResourceType=volume,Tags=[{Key=cost-center,Value=cc123}]'