15

I've created an autoscaling group on EC2 and it's working just fine. Servers scale up and down depending on load. I'd like to have a little more info on the management side and am wondering if there's a way to get the autoscaling group to dynamically add names to the instances that it boots up. I'm referring to adding a Tag with key=Name and value=autogeneratedid.

For example, if I had an autoscaling group called test-group, servers would boot up with the following names:

test-group-1
test-group-2
test-group-3
...

I'd like to find them an enumerate them in the EC2 Management Console, but right now they're just showing up as "empty" names (the Tag key=Name isn't explicitly set on the instances).

Any ideas?

Eric Hammond
  • 22,089
  • 5
  • 66
  • 75
joelpoloney
  • 419
  • 4
  • 13

1 Answers1

5

In order to get the tags to be set on the instances, make sure you are setting the PropagateAtLaunch flag ("p=1") for the tag in the Auto Scaling Group.

You'll want to read this section in Amazon's documentation:

http://docs.amazonwebservices.com/AutoScaling/latest/DeveloperGuide/ASTagging.html

As far as having Amazon dynamically adding parameters to the tag value, I'm not aware of any such feature.

Eric Hammond
  • 22,089
  • 5
  • 66
  • 75
  • 4
    I'm getting tags set on the instances (ex: production vs. staging environment), but the Name tag isn't getting set on them. It would be nice if they could enumerate them, though. – joelpoloney Oct 10 '12 at 05:02
  • hm, curious. I'll do some testing. – Eric Hammond Oct 10 '12 at 08:36
  • @fffanatics Any resolution? I just bumped across this problem today. – Scott A Apr 17 '14 at 22:28
  • No, never really bothered to deal with it. It hasn't been an issue for us though. Sorry I couldn't be of any more help! – joelpoloney Apr 21 '14 at 06:01
  • 2
    This propagation allows a static tag on auto scale group to cascade or "propagate" down to all instances in the group. The original post asked for if there was a way to enumerate the instances in the group so that there would be unique name tags per member of the group. You can use boto to do this, but it will require creating a role that has access to tagging resources. It might be best to leave the name alone for autoscaling. Often in an autoscaling setup, instances come and go so names aren't that helpful. – Douglas Ferguson Sep 08 '14 at 02:44
  • Here's some dynamic hostname stuff that might be a good starting point: http://stumblinginthedark.com/aws/newrelic/api/2015/10/09/autoscaling_with_newrelic.html https://github.com/wtfiwtz/stable-ec2-hostnames – Nigel Sheridan-Smith Jun 21 '17 at 07:01