【发布时间】:2017-05-17 21:09:23
【问题描述】:
执行查询:
aws ec2 run-instances --image-id ami-7a85a01a --security-group-ids sg-756ae512 --count 1 --instance-type t2.micro --tag-specifications ResourceType=instance,Tags=[{Key=webserver,Value=production}] --subnet-id subnet-cc0b0e8a
它抛出一个错误说:
Unknown options: --tag-specifications, ResourceType=instance,Tags=[{Key=webserver,Value=production}]
有人知道这是否被贬低,还是语法与预期不同?我一直在绕着这个圈子跑。
新语法的可能解决方案:
aws ec2 run-instances --image-id ami-xxxxxxxxxx --security-group-ids sg-ef95c791 --count 1 --instance-type m4.2xlarge --key-name mypemkey --query Reservations[*].Instances[*].[PublicIpAddress,InstanceId]
我能想到的最好的,似乎正在工作:
aws ec2 run-instances --image-id ami-7a85a01a --count 1 --instance-type t2.micro --key-name mykeypair --subnet-id sn-756ae512 --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=production}]' --associate-public-ip-address --output=text
【问题讨论】:
-
您的编辑只显示您删除了
--tag-specification选项,WTF? -
正确答案如下。需要升级。大多数情况下,文档告诉我我无法在实例创建过程中添加标签。我发布了我工作的最后一个命令,它将返回实例 ID,它可以传递给下一个命令 - 以标记实例。
标签: amazon-web-services amazon-ec2 aws-cli