简体   繁体   English

如何通过Amazon EC2 API修改实例的“Name”属性?

[英]How can I modify 'Name' attribute of an instance via the Amazon EC2 API?

I'd like to be able to create/modify the 'Name' attribute of an EC2 instance, ie, the field shown by 'Name' in the web UI. 我希望能够创建/修改EC2实例的“名称”属性,即Web UI中“名称”所示的字段。

Amazon EC2 Web UI

I am quite comfortable spawning instances via the Amazon API, however I cannot find any references to instance naming in the API reference . 通过Amazon API生成实例非常方便,但是我在API参考中找不到对实例命名的任何引用 How can I create an instance with the Name attribute set, or modify the Name of an existing instance? 如何创建具有Name属性集的实例,或修改现有实例的Name?

The Name attribute is just a regular tag, that happens to be available/used by default for many resources, including Amazon EC2 instances. Name属性只是一个常规标记,默认情况下可用于许多资源,包括Amazon EC2实例。

Accordingly, you can change it eg via the Amazon EC2 API Tools (ec2-create-tags, ec2-describe-tags, ec2-delete-tags), which facilitate the respective APIs in turn, see section API within Using Tags for more details: 因此,您可以通过Amazon EC2 API工具 (ec2-create-tags,ec2-describe-tags,ec2-delete-tags)进行更改,这些工具依次为各自的API提供便利,请参阅使用标签中的 API部分了解更多详情:

Summary of available API actions: 可用的API操作摘要:

  • CreateTags — Adds a set of tags to a set of resources. CreateTags - 向一组资源添加一组标记。 You also use this to update a tag's value (overwrites the existing value). 您还可以使用它来更新标记的值(覆盖现有值)。 [emphasis mine] [强调我的]

  • DeleteTags — Deletes a set of tags from a set of resources. DeleteTags - 从一组资源中删除一组标记。

  • DescribeTags — Lists your tags, or just certain ones you specify. DescribeTags - 列出您的标签,或仅列出您指定的标签。

These actions are further detailed in the Amazon Elastic Compute Cloud API Reference as usual: 像往常一样, Amazon Elastic Compute Cloud API Reference中进一步详细说明了这些操作:

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

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