如何修改ec2实例的实例名称
我想修改亚马逊实例的“名称”属性。请参阅随附的屏幕截图。我需要以编程方式完成此操作,但在 EC2 API 中找不到如何设置它的任何地方。
如果重要的话,我将通过他们的 API 通过现场请求来启动这些。我想设置我标记的字段,下图中的“设置此名称”。
I would like to modify the "name" attribute of an amazon instance. See attached screenshot. I need to do it programmatically, but can't find anywhere in the EC2 API how to set that.
If it matters, I'm launching these via a spot request through their API. I would like to set the field that I tagged, "set this name" in the image below.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这可能会有所帮助......
有点快速和肮脏,但你明白了。
This might help...
kind of quick and dirty, but you get the idea.
您可以通过 AWS 控制台 UI 执行此操作:
You can do it through AWS console UI:
到 2021 年,这可以通过 AWS 控制台完成,方法是转到 EC2 > 实例,单击实例 ID,然后在底部面板中单击标签选项卡,然后单击管理标签。从那里,您只需更改名称标记的值,然后单击保存即可应用。
In 2021 this can be done from the AWS console, by going to EC2 > Instances, clicking the instance ID, then in the bottom panel clicking on the Tags tab, and clicking Manage tags. From there, you can simply change the value of the Name tag then click Save to apply.
进一步深入研究 API,我找到了我想要的东西。
这些被称为标签。您可以将它们分配给几乎任何 aws 实体(有些情况除外,例如,您不能将标签添加到弹性 IP)。
您可以通过 API 设置键名/键值对。文档位于:http://docs.amazonwebservices.com/AWSEC2 /latest/APIReference/ApiReference-query-CreateTags.html
然后您可以通过这些标签过滤结果,或选择在 Web 界面中显示它们。
Further digging into the API and I found what I was looking for.
These are known as tags. You can assign them to nearly any aws entity (some things are excepted, e.g., you can't add a tag to an elastic ip).
You can set keyname/keyvalue pairs through the API. Documentation is here: http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateTags.html
Then you can filter results by these tags, or choose to display them in the web interface.