Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Does anyone know how to tag an AWS Autoscale spun EC2 instance via boto? I would like all Autoscale EC2 instances to have a prefix of 'as-'.


share|improve this question
EC2 doesn't autoscale by itself. How are you initiating it? – jamieb Aug 21 '12 at 5:59
The EC2 instances are scaled up or down based on CloudWatch alarms. – Binary Maze Aug 22 '12 at 2:51

I figured this out.

You assign a 'Name' tag to an AWS Autoscale group after it is created. The trick is to set the 'propagate_at_launch' flag to True when passing it to the Autoscale Tag object. This flag when set to True ensures that the tag will be applied to any Autoscale spun EC2 instance after the tag is created. An example follows:

import boto
from boto.ec2.autoscale import Tag

# Make sure your access keys are stored in ~/.boto
conn = boto.connect_autoscale()

# This assumes you have already setup an elastic load balancer
# and a launch configuration
ag = AutoScalingGroup(group_name=group_name,

# Create auto scaling group

# Fetch the autoscale group after it is created
auto_scaling_group = conn.get_all_groups(names=[group_name])[0]

# Create a Tag for the austoscale group
as_tag = Tag(key='Name',
             value = 'as-instance',

# Add the tag to the autoscale group

Voila! Now whenever an EC2 instance is spun from this Autoscale group based on CloudWatch Alarms i.e. scale up based on CPU utilization thresholds or some other metric...that instance will have a name value = 'as-instance'


share|improve this answer
For the record, with the most recent version of boto you can also specify tags parameter on creation of the auto scaling group. – j0nes Oct 23 '13 at 14:57
It is important to note that a tag key can be anything, but if you want it to be the "Name" that shows up in the instance list as the official name, then case matters. In other words, "Name" != "name". – SunSparc Jan 17 '14 at 19:55
Another helpful note: Tags can apply to both AutoScaling Groups and Instances. When a tag is added to an ASG, that does not mean that the instances of that group will be tagged. The propagate_at_launch=True property tells the ASG to apply the tag to the instances it launches as well. – SunSparc Jan 17 '14 at 22:12
propagate_at_launch=True property does not mean at launch... it means at a point just before the server goes live. These tags will not be available at the point when the userdata script is run, or if CodeDeploy installs software during start up. – Michael Shaw Apr 27 at 16:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.