Menu
Amazon Elastic Compute Cloud
User Guide for Linux Instances

Listing and Filtering Your Resources

You can get a list of some types of resource using the Amazon EC2 console. You can get a list of each type of resource using its corresponding command or API action. If you have many resources, you can filter the results to include only the resources that match certain criteria.

Advanced Search

Advanced search allows you to search using a combination of filters to achieve precise results. You can filter by keywords, user-defined tag keys, and predefined resource attributes.

The specific search types available are:

  • Search by keyword

    To search by keyword, type or paste what you’re looking for in the search box, and then choose Enter. For example, to search for a specific instance, you can type the instance ID.

  • Search by fields

    You can also search by fields, tags, and attributes associated with a resource. For example, to find all instances in the stopped state:

    1. In the search box, start typing Instance State. As you type, you'll see a list of suggested fields.

    2. Select Instance State from the list.

    3. Select Stopped from the list of suggested values.

    4. To further refine your list, select the search box for more search options.

  • Advanced search

    You can create advanced queries by adding multiple filters. For example, you can search by tags and see instances for the Flying Mountain project running in the Production stack, and then search by attributes to see all t2.micro instances, or all instances in us-west-2a, or both.

  • Inverse search

    You can search for resources that do not match a specified value. For example, to list all instances that are not terminated, search by the Instance State field, and prefix the Terminated value with an exclamation mark (!).

  • Partial search

    When searching by field, you can also enter a partial string to find all resources that contain the string in that field. For example, search by Instance Type, and then type t2 to find all t2.micro, t2.small or t2.medium instances.

  • Regular expression

    Regular expressions are useful when you need to match the values in a field with a specific pattern. For example, search by the Name tag, and then type ^s.* to see all instances with a Name tag that starts with an 's'. Regular expression search is not case-sensitive.

After you have the precise results of your search, you can bookmark the URL for easy reference. In situations where you have thousands of instances, filters and bookmarks can save you a great deal of time; you don’t have to run searches repeatedly.

Combining search filters

In general, multiple filters with the same key field (for example, tag:Name, search, Instance State) are automatically joined with OR. This is intentional, as the vast majority of filters would not be logical if they were joined with AND. For example, you would get zero results for a search on Instance State=running AND Instance State=stopped. In many cases, you can granulate the results by using complementary search terms on different key fields, where the AND rule is automatically applied instead. If you search for tag: Name:=All values and tag:Instance State=running, you get search results that contain both those criteria. To fine-tune your results, simply remove one filter in the string until the results fit your requirements.

Listing Resources Using the Console

You can view the most common Amazon EC2 resource types using the console. To view additional resources, use the command line interface or the API actions.

To list EC2 resources using the console

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. In the navigation pane, choose the option that corresponds to the resource, such as AMIs or Instances.

    
                     Amazon EC2 console navigation pane
  3. The page displays all the available resources.

Filtering Resources Using the Console

You can perform filtering and sorting of the most common resource types using the Amazon EC2 console. For example, you can use the search bar on the instances page to sort instances by tags, attributes, or keywords.

You can also use the search field on each page to find resources with specific attributes or values. You can use regular expressions to search on partial or multiple strings. For example, to find all instances that are using the MySG security group, enter MySG in the search field. The results will include any values that contain MySG as a part of the string, such as MySG2 and MySG3. To limit your results to MySG only, enter \bMySG\b in the search field. To list all the instances whose type is either m1.small or m1.large, enter m1.small|m1.large in the search field.

To list volumes in the us-east-1b Availability Zone with a status of available

  1. In the navigation pane, choose Volumes.

  2. Click on the search box, select Attachment Status from the menu, and then select Detached. (A detached volume is available to be attached to an instance in the same Availability Zone.)

  3. Click on the search box again, select State, and then select Available.

  4. Click on the search box again, select Availability Zone, and then select us-east-1b.

  5. Any volumes that meet this criteria are displayed.

To list public 64-bit Linux AMIs backed by Amazon EBS

  1. In the navigation pane, choose AMIs.

  2. In the Filter pane, select Public images, EBS images, and then your Linux distribution from the Filter lists.

  3. Type x86_64 in the search field.

  4. Any AMIs that meet this criteria are displayed.

Listing and Filtering Using the CLI and API

Each resource type has a corresponding CLI command or API request that you use to list resources of that type. For example, you can list Amazon Machine Images (AMI) using ec2-describe-images or DescribeImages. The response contains information for all your resources.

The resulting lists of resources can be long, so you might want to filter the results to include only the resources that match certain criteria. You can specify multiple filter values, and you can also specify multiple filters. For example, you can list all the instances whose type is either m1.small or m1.large, and that have an attached EBS volume that is set to delete when the instance terminates. The instance must match all your filters to be included in the results.

You can also use wildcards with the filter values. An asterisk (*) matches zero or more characters, and a question mark (?) matches exactly one character. For example, you can use *database* as a filter value to get all EBS snapshots that include database in the description. If you were to specify database as the filter value, then only snapshots whose description equals database would be returned. Filter values are case sensitive. We support only exact string matching, or substring matching (with wildcards). If a resulting list of resources is long, using an exact string filter may return the response faster.

Your search can include the literal values of the wildcard characters; you just need to escape them with a backslash before the character. For example, a value of \*amazon\?\\ searches for the literal string *amazon?\.

For a list of supported filters per Amazon EC2 resource, see the relevant documentation:

Note

The response of a describe action includes information about any tags that are applied to your resources. However, when describing multiple resources, the results may be eventually consistent and may not return all of your tags. To confirm the tags for a resource, describe a single resource.