自动缩放时如何更改新的实例标签名称 [英] How to change new instance tag Name when auto scaling

查看:68
本文介绍了自动缩放时如何更改新的实例标签名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已根据我也创建的指标在 AWS 帐户上创建了一个新的警报. 我使用此警报自动缩放.启动新实例时,我使用User Data字段设置此新实例. 我面临的唯一问题是我无法修改此新实例的标签(特别是标签 Name ). 如果我不进行更改,则所有新实例的名称都将与当前设置不兼容.

I've created a new Alarm on my AWS account based on a Metric that I also have created. I use this alarm to auto scale. When launching new instances I'm using User Data field to set up this new instance. The only problem I'm facing is that I cannot modify the tags (specially the tag Name) of this new instance. If I don't change that, all the new instances will have the same name which won't work with my current setup.

有可能解决吗?

推荐答案

您可以使用AWS cli工具和实例元数据在其自己的用户数据脚本中为该实例设置新的Name标签.看起来像这样:

You can set up a new Name tag for the instance in its own user data script using AWS cli tools and the instance metadata. It would look like this:

aws ec2 create-tags \
  --resources $(curl -s http://169.254.169.254/latest/meta-data/instance-id) \
  --tag Key=Name,Value=MyNewNiceName \
  --region=us-east-1

请参阅: http://docs.aws. amazon.com/cli/latest/reference/ec2/create-tags.html

这篇关于自动缩放时如何更改新的实例标签名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆