aws cli运行带有名称标签和EBS卷的实例

时间:2017-07-06 14:14:47

标签: amazon-web-services aws-cli

我尝试使用cli在命令行上将新的EC2实例启动到AWS中。我需要做的是应用名称标签并添加EBS卷。 EBS卷也应该有名称标签。这是我到目前为止所做的。

我收到了使用错误:

λ aws ec2 run-instances --image-id ami-xxxxx --count 1 --instance-type r3.xlarge --key-name timd --security-group-ids sg-xxxxx --subnet-id subnet-xxxxx --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=ENC_TEST}]' 'ResourceType=volume,Tags=[{Key=Engagement,Value=8000xxxx}]' --block-device-mappings 'DeviceName=/dev/sdf,VirtualName=data,Ebs={Encrypted=yes,DeleteOnTermination=yes,VolumeSize=250,VolumeType=string}' --profile=govcloud-nonprod
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: --tag-specifications, 'ResourceType=volume,Tags=[{Key=Engagement,Value=800000xxxx}]', 'ResourceType=instance,Tags=[{Key=Name,Value=ENC_TEST}]'

有人可以帮助我超越这一点吗?

1 个答案:

答案 0 :(得分:2)

--tag-specificationsMarch 2017

后端引入的功能

确保更新您的aws CLI版本以反映此更改。

同样--block-device-mapping不正确,定义为

        {
          "DeviceName": "string",
          "VirtualName": "string",
          "Ebs": {
            "Encrypted": true|false,
            "DeleteOnTermination": true|false,
            "Iops": integer,
            "SnapshotId": "string",
            "VolumeSize": integer,
            "VolumeType": "standard"|"io1"|"gp2"|"sc1"|"st1"
          },
          "NoDevice": "string"
        }
        ...

所以你应该

--block-device-mappings "[{\"DeviceName\":\"/dev/sdf\",\"VirtualName\":\"data\",\"Ebs\":{\"Encrypted\"=true,\"DeleteOnTermination\"=true,\"VolumeSize\"=250,/"VolumeType\"=\"standard\"}}]"