简体   繁体   English

如何使用 AWS Cli 中的标签从现有 ec2 创建 AMI?

[英]How to create AMIfrom existing ec2 with tags from AWS Cli?

I'm trying to create a new Ami from my existing ec2 instance with tags.我正在尝试从我现有的带有标签的 ec2 实例创建一个新的 Ami。 I tried the following command and it doesn't work.我尝试了以下命令,但它不起作用。

aws ec2 create-image --instance-id i-xxxxxxxxxxxxx --name "TEST_AMI" --no-reboot --tag-specifications 'ResourceType=instance,Tags=[{Key=name,Value=TEST_AMI} aws ec2 create-image --instance-id i-xxxxxxxxxxxxx --name "TEST_AMI" --no-reboot --tag-specifications 'ResourceType=instance,Tags=[{Key=name,Value=TEST_AMI}

and its return following error.及其返回以下错误。

usage: aws [options] [...] [parameters] To see help text, you can run: aws help aws help aws help Unknown options: --tag-specifications, ResourceType=instance,Tags=[{Key=name,Value=TEST_AMI}]用法:aws [options] [...] [parameters] 要查看帮助文本,您可以运行:aws help aws help aws help 未知选项:--tag-specifications, ResourceType=instance,Tags=[{Key=name,值=TEST_AMI}]

I just need to do both tasks in one command.我只需要在一个命令中完成这两项任务。

The value for the ResourceType is invalid. ResourceType的值无效。 From create-image documentation :从创建图像文档

The tags to apply to the AMI and snapshots on creation.在创建时应用于 AMI 和快照的标签。 You can tag the AMI, the snapshots, or both.您可以标记 AMI、快照或两者。

  • To tag the AMI, the value for ResourceType must be image .要标记 AMI,ResourceType 的值必须是image
  • To tag the snapshots that are created of the root volume and of other Amazon EBS volumes that are attached to the instance, the value for ResourceType must be snapshot .要标记为根卷和附加到实例的其他 Amazon EBS 卷创建的快照, ResourceType 的值必须是snapshot The same tag is applied to all of the snapshots that are created.相同的标签应用于创建的所有快照。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM