2017-07-06 83 views
1

我試圖在命令行中使用cli在AWS中啓動新的EC2實例。我需要做的是應用名稱標籤並添加EBS卷。 EBS卷也應該有名稱標籤。這是我迄今爲止所擁有的。aws cli使用名稱標籤和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}]' 

有人可以幫助我過去的這個地步?

回答

2

--tag-specifications是一個功能引入回March 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\"}}]"