How to tag your AWS resources efficiently

aws-logoIn AWS we can tag our EC2 resources to manage the environment. We can categorize the resources by assigning our own metadata to each of them in form of tags. You can tag your resources in many ways ex: Environment Based, Application Based and Role Based. Tags are mainly helping us to understand the AWS billing. In this tutorial I will show you how to tag your AWS resources efficiently. Before this we should know about, which resources we can tag and which we can’t. Below is the list describing about the tagging support and restriction of AWS resources.


How AWS Tag Works:

As I told you before that tags are noting but some user defined metadata associated with AWS resources. For example for my production environment I am using three tags: Name, CostCenter and Stack. Each of the tags has their own value: Name=, CostCenter = linuxfunda, Stack = Production. For the development environment the tags looks like: Name=, CostCenter = linuxfunda, Stack = development. The difference between Development and Production tags are the values.  You can assign up to 10 tags to an AWS resource depending on your need.

We can use AWS console or CLI or API to tag our resources. But the main problem is AWS tagging has some limitations. Each tag associated with a single AWS resource applies only to that particular resource. The tags cannot be propagated to the additional resources attached to the resource. So we need to manually tag them too.

How to tag an EC2 instance:

Now I will give you an example to tag an EC2 instance using AWS command line tools:

The above command will tag the instance bearing ID i-7d3e5a2f. You can combine multiple instance ID to tag simounteniously.

Below is an example to tag EC2 autoscaling group:

Create a lunch configuration:

Create a AutoScaling Group:

Now all the instance of the AutoScaling group “MyTagASG” will be tagged with the above supplied value. In the above mentioned command the user has specified the tag with the command --tag . The parameters for the command are:

k=Key (Any Name to identify the key. E.g. Version, Cost Center, Name, etc)

v=Value of the key

p= The propagate-at-launch flag. If the user wants all the newly launched EC2 instances to be tagged with the same key pair, set this flag as true.

After tagging all our EC2 instances now we will tag the additional resources associated with our Instances like EBS volumes and Snapshots etc.. It’s very difficult to recognize and tag manually to each of the additional resources of the EC2 instances, when you run a large foot prints on AWS. A small automation named Graffiti Monkey is available to goes around tagging things automatically. It helps us to reduce hours of manual labor on a large AWS footprints. By looking at the tags of an EC2 instance, it copies those tags to the EBS Volumes that are attached to it, and then copies those tags to the EBS Snapshots as well.

Installation Step:

There are two ways to install Graffiti Monkey: You can install Graffiti Monkey using the usual PyPI channels or you can install it from source.

Using source:


It will identify the tags associated with EC2 instance and applies them to dependent resources like EBS volumes and snapshots.

The following two tabs change content below.

Tapas Mishra

Sr. Engineer (DevOps)
Loves to work on Opensource products. Having experience on Linux environment. Knowledge on Public cloud services like AWS, Rackspace, DigitalOcean, Linode. Please don't hesitate to give a comment on the posts. Your comments are my strength.

Leave a Reply