AWS News Blog

New Amazon EC2 Feature: Filtering

Many of our customers create large numbers of EC2 resources. Some of them run hundreds or thousands of EC2 instances, create thousands of EBS volumes, and retain tens of thousands of EBS volume snapshots.

This growth has meant that the corresponding Describe APIs (DescribeInstances, DescribeVolumes, and DescribeSnapshots, to name a few) can return results that are very long and somewhat tedious to process.

In order to make client applications simpler and more efficient, you can now specify filters when you call the EC2 “Describe” functions (except those having to do with attributes or datafeed subscriptions for Spot instances).

You can provide one or more filters as part of your call to a Describe function. Each filter consists of a case-sensitive name and a value. Values are text strings or XML text string representations of non-textual (e.g. Boolean) values. Filter values can use the “*” to match zero or more characters, or the “?” to match a single character.

You can also combine multiple filters. Multiple filters with the same name are OR-ed together and then AND-ed with the other filters. You could, for example, call DescribeInstances and ask for all of your m1.large instances that are running a Ubuntu AMI in the us-east-1a or us-east-1b Availability Zones.

The filters are also supported by the EC2 command-line tools via the “–filter name=value” option.

Tool vendors will be able to make use of this new flexibility to create faster and more powerful EC2 management tools.

Read more about filtering in the newest version of the EC2 User Guide.

Next feature: Bring Your Own Keypair.

— 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.