AWS News Blog

Query Your EC2 Instances Using Tag and Attribute Filtering

As an Amazon Elastic Compute Cloud (Amazon EC2) user, you probably know just how simple and easy it is to launch EC2 instances on an as-needed basis. Perhaps you got your start by manually launching an instance or two, and later moved to a model where you launch instances through a AWS CloudFormation template, Auto Scaling, or in Spot form.

Today we are launching an important new feature for the AWS Management Console. You can now find the instance or instances that you are looking for by filtering on tags and attributes, with some advanced options including inverse search, partial search, and regular expressions.

Instance Tags
Regardless of the manner in which you launch them, you probably want to track the role (development, test, production, and so forth) internal owner, and other attributes of each instance. This becomes especially important as your fleet grows to hundreds or thousands of instances. We have long supported tagging of EC2 instances (and other resources) for many years. As you probably know already, you can add up to ten tags (name/value pairs) to many types of AWS resources. While I can sort by the tags to group like-tagged instances together, there’s clearly room to do even better! With today’s launch, you can use the tags that you assign, along with the instance attributes, to locate the instance or instances that you are looking for.

Query With Tags & Attributes
As I was writing this post, I launched ten EC2 instances, added Mode and Owner tags to each one (supplementing the default Name, and then configured the console to show the tags and their values:

The new filter box offers many options. I’ll do my best to show them all to you!

In the examples that follow, I will filter my instances using the tags that I assigned to the instances. I’ll start with simple examples and work up to some more complex ones. I can filter by keyword. Let’s say that I am looking for an instance and can only recall part of the instance id (this turns out to be a very popular way to search). I enter the partial id (“2a27”) in to the filter box and press Enter to find it:

Let’s say that I want to find all of the instances where I am listed as Owner. I click in the Filter box for some guidance:

I select the Owner tag and select from among the values presented to me:

Here are the results:

I can add a second filter if I want to see only the instances where I am the owner and the Mode is “Production”:

I can also filter by any of the attributes of the instance. For example, I can easily find all of the instances that are in the Stopped state:

And I can, of course, combine this with a filter on a tag. I can find all of my stopped instances:

I can use an inverse search to find everyone else’s stopped instances (I simply prefix the value with an exclamation mark):

I can also use regular expressions to find instances owned by Kelly or Andy:

And I can do partial matches to compensate for inconsistent naming:

I can even filter by launch date to find instances that are newer or older than a particular time:

Finally, the filter information is represented in the console URL so that you can bookmark your filters or share them with your colleagues:

Filter Now
This feature is available now and you can start using it today. It works for EC2 instances now; we expect to make it available for other types of EC2 resources before too long.

Jeff;

Jeff Barr

Jeff Barr

Jeff Barr is Chief Evangelist for AWS. He started this blog in 2004 and has been writing posts just about non-stop ever since.