Jam*_*mes 0 amazon-ec2 amazon-web-services aws-cli
我指的是以下 AWS 文档,尝试使用 CLI(来自 Windows)来启动具有在启动时指定的标签的 EC2 实例:
https://docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.html https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#Using_Tags_CLI
我遇到了一些问题,所以我决定尝试文档中指定的确切命令:
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}]'
Run Code Online (Sandbox Code Playgroud)
这会导致以下错误:
Error parsing parameter '--tag-specifications': Expected: '=',
received: ''' for
input:
'ResourceType=instance,Tags=[{Key=webserver,Value=production}]'
^
Run Code Online (Sandbox Code Playgroud)
那么,究竟如何指定运行实例的标签呢?
经过多次挫折和搜索后,我偶然发现了一个页面,该页面解释了运行实例的语法记录不正确。我理解的日语足以看到示例上的“错误”和“正确”标签,并看到标签规范值周围的单引号导致它失败。正确的语法是:
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}]
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4456 次 |
最近记录: |