Finding EC2 Instances Using Tag Filters

We have a large number of EC2 instances in our infrastructure and we use tags to help us organize and configure those instances. For our aircom infrastructure, our instances use tags containing the string ‘aircom’. For example, the main aircom instances are tagged with just ‘aircom’, while supporting instances are tagged with something like ‘aircom_emulation’. Recently, I was looking for an overview of just our aircom instances in particular, so I headed over to the handy AWS EC2 Dashboard and entered ‘aircom’ into the instance filter. This is where the problem with our tagging system first became apparent. I got a long list of all our instances with aircom anywhere in the tags, which was not helpful. Wishing for a better list, but not wanting to re-tag all of our instances, I looked up tag filters in the AWS docs. Luckily AWS filters support regular expressions. Appending ‘$’ to the search string tells the filter to match the end of the string, so using ‘aircom$’ gave me the results I was looking for.

Screen Shot 2016-01-21 at 3.56.01 PM

There are a bunch of advanced filtering techniques listed in the documentation, and I found it helpful to skim through that entire page. One search type I know I’ll be using a lot is inverse search. Prefixing a ‘!’ before any search string will return everything that doesn’t match that string. Let’s say I wanted to ensure that I didn’t make any changes to production machines while browsing around the EC2 Dashboard. I could add a ‘!production’ filter and feel secure that I won’t be messing around with our production servers.

Screen Shot 2016-01-21 at 3.56.13 PM

Navigating the EC2 Dashboard is an important part of my job, and little tricks like this invariably make my job easier, and provide peace of mind as I go through my day.

Tags: ,


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s