Filter Expressions

Create More Specific Diagrams with Filter Expressions

Filters provide the flexibility to visualize exactly what’s needed for your use-case

Overview

Filter expressions allow you to visualize a specific subset of your AWS resources. You can use filter expressions in:

  • UI: Simply click the search icon below the Views select box and enter your filter expression.
  • Developer API: Pass filter expressions as a query string parameter named filter to visualize a specific subset of your AWS environment.

To help you create filter expressions more efficiently, we provide an auto-complete feature that suggests available parameters and values as you type (based on your selected account and region). This feature helps you quickly build filter expressions without memorizing all the possible parameters.

Syntax

You can combine one or more of the following syntaxes with operators to create complex filter expressions:

  • vpcId=<id>: Targets all resources associated with a specific VPC (e.g., vpcId=vpc-123).
  • tag=<value>:<key>: Filters by resource tags (e.g., tag=stage:dev).
  • <resource-parameter>=<value>: Filters resources that match a specific resource parameter, like elementType="EC2 Instance", subnetId=subnet-123, or privateIpAddress=172.31.5.193.

Operators and Modifiers

The expression syntax provides operators and modifiers to create complex filter expressions, allowing users to define exactly what should be visualized in the diagram. The following operators and modifiers are supported:

AND Operator

The AND operator lets you specify multiple conditions to narrow or expand your results. For example:

  • vpcId=vpc-123 and tag=stage:dev returns all resources within VPC vpc-123 that have the tag stage:dev.
  • vpcId=vpc-123 and elementType="EC2 Instance" returns all resources within VPC vpc-123 that are EC2 instances.
  • vpcId=vpc-123 and subnetId=subnet-123 returns all resources within VPC vpc-123 that are in the subnet subnet-123.

OR Operator

The OR operator allows you to specify multiple conditions to broaden your results. For example:

  • vpcId=vpc-123 or vpcId=vpc-321 returns all resources within VPCs vpc-123 or vpc-321.

!= Operator

The != operator excludes resources that match specific conditions. For example:

  • vpcId=vpc-123 and instanceType!=t2.small returns all resources within VPC vpc-123 where the instance type is not t2.small.
  • vpcId=vpc-123 and state!=stopped returns all resources within VPC vpc-123 where the state is not stopped.

* Wildcard

The wildcard * provides flexibility when specifying filter values. For example:

  • vpcId=* returns all resources related to any VPC.
  • vpcId!=* returns all resources that are not related to any VPC.
  • tag=*:* returns all resources that have tags.
  • tag!=*:* returns all resources that do not have tags.
  • vpcId=vpc-123 and privateIpAddress=10.*.5.* returns all resources within VPC vpc-123 where the private IP address matches the pattern 10.*.5.*.

Grouping with Parentheses

Parentheses () allow you to group logical conditions to create more complex filter expressions. For example:

  • vpcId=vpc-123 and (tag=stage:dev or tag=cost-center:billing) returns all resources within VPC vpc-123 that have either the tag stage:dev or cost-center:billing.
  • vpcId=vpc-123 and (elementType="EC2 Instance" or elementType=*Balancer) returns all EC2 instances or load balancers within VPC vpc-123.

Case Sensitivity

There are a few things you should know before you start using the expression syntax:

  • Parameter names (e.g., vpcId=..., elementType=...) and search operators (AND, OR) are case-insensitive, meaning you can write them in any format that works for you and your team.
  • Parameter values (e.g., ...=vpc-123, ...=STAGE:dev) are case-sensitive and must be specified exactly as they appear in your AWS environment.