Home / AWS

AWSCheat sheetBeginner

AWS Resource Explorer cheat sheet: find any resource across Regions and accounts, including untagged ones

Turn on Resource Explorer with an aggregator index, then answer "where is this resource?" and "what is untagged?" in seconds. Setup commands, query syntax and ready-made searches.

Deepak Bhardwaj6 min read

Applies toAWS Resource Explorer (resource-explorer-2 API), AWS Organizations, AWS CLI v2

When to use it

Someone asks "which account owns this bucket?", "what's still running in ap-southeast-2?" or "show me everything with no Owner tag". Looping describe-* calls over every Region and service is slow. Resource Explorer keeps an index of your resources and lets you search all Regions, and optionally every account in your organization, with one query.

Check the current pricing page for cost. Note that it only shows resource metadata: names, ARNs, Region, type, account and tags. For configuration details, follow up with the service's own CLI or with AWS Config.

Setup

Turn on indexes in every Region

Each Region needs a LOCAL index. One Region gets promoted to AGGREGATOR, which receives a copy of every other Region's index.

for r in $(aws ec2 describe-regions --query "Regions[].RegionName" --output text); do
  echo "== $r"
  aws resource-explorer-2 create-index --region "$r" 2>&1 | grep -E 'Arn|State|Conflict' || true
done

Promote one Region to aggregator (pick your home Region):

HOME_REGION=eu-west-1
INDEX_ARN=$(aws resource-explorer-2 get-index --region $HOME_REGION --query Arn --output text)
aws resource-explorer-2 update-index-type --arn "$INDEX_ARN" --type AGGREGATOR --region $HOME_REGION
aws resource-explorer-2 get-index --region $HOME_REGION --query "{type:Type,state:State}"

Warning

An account can have only one aggregator index. If you demote an aggregator back to LOCAL, you must wait 24 hours before you can promote another Region. Pick the Region carefully.

Replication into the aggregator can take several hours after you first turn it on. Results for other Regions appear gradually.

Create a view and make it the default

Searches run through a view. Include the tags property, or the tag filters below return nothing.

VIEW_ARN=$(aws resource-explorer-2 create-view --region $HOME_REGION \
  --view-name all-resources --included-properties Name=tags \
  --query View.ViewArn --output text)
aws resource-explorer-2 associate-default-view --view-arn "$VIEW_ARN" --region $HOME_REGION

A view can also have a fixed filter that is AND-ed with every query. This is useful for a view you give to a team:

aws resource-explorer-2 create-view --region $HOME_REGION --view-name ec2-only \
  --included-properties Name=tags --filters FilterString="service:ec2"

Organization-wide views

create-view --scope accepts the ARN of an account, an OU or the whole organization. A view scoped to the organization searches every member account that has indexes. Multi-account search needs extra setup in AWS Organizations: trusted access and usually a delegated administrator, plus indexes in the member accounts. Follow the current Resource Explorer user guide for those steps.

aws resource-explorer-2 create-view --region $HOME_REGION --view-name org-all \
  --included-properties Name=tags \
  --scope arn:aws:organizations::111122223333:organization/o-exampleorgid

Query syntax

Filter Example Notes
service: service:rds Service name
resourcetype: resourcetype:ec2:instance Lowercase service:type, not AWS::EC2::Instance
region: region:us-east-1, region:eu-*, region:global global covers IAM, CloudFront and similar
accountid: accountid:444455556666 Useful in organization views
id: id:arn:aws:s3:::my-bucket Full ARN
tag: tag:Environment=prod Key and value
tag.key: tag.key:Owner Key only
tag.value: tag.value:payments Value only
tag:none tag:none No user-created tags
tag:all tag:all Has at least one user-created tag
resourcetype.supports:tags resourcetype.supports:tags tag:none Limit to types that can be tagged

Rules:

  • Separate filters are AND-ed. Comma-separated values within one filter are OR-ed: region:us-east-1,us-west-2.
  • - negates: -tag.key:Owner. Free text keywords match names and other fields. "exact phrase" and a trailing * wildcard work.
  • Matching is not case-sensitive.
  • Tags on IAM users and roles are not indexed, so tag filters don't find them.

Tip

If the query string starts with -, the CLI reads it as an option. Use an equals sign: --query-string="-tag:none region:us-east-1", or put a positive filter first.

Ready-made searches

Search with the default view (add --view-arn to use another one):

q() { aws resource-explorer-2 search --region $HOME_REGION --query-string "$1" \
  --query "Resources[].[Region,OwningAccountId,ResourceType,Arn]" --output text; }
Question Query
Where is this bucket or instance? q "my-app-logs" or q "id:arn:aws:ec2:eu-west-1:111122223333:instance/i-0abc..."
Every EC2 instance in all Regions q "resourcetype:ec2:instance"
Anything running in Regions we don't use q "region:ap-* -region:ap-southeast-2"
Taggable resources with no tags q "resourcetype.supports:tags tag:none"
Resources missing an Owner tag q "resourcetype.supports:tags -tag.key:Owner"
Prod resources outside the approved Region q "tag:Environment=prod -region:eu-west-1"
Everything from one CloudFormation stack q "tag:aws:cloudformation:stack-name=orders-prod"
Everything in one member account q "accountid:444455556666"
Untagged EBS volumes q "resourcetype:ec2:volume tag:none"

Count results per type to get a quick inventory:

aws resource-explorer-2 search --region $HOME_REGION --query-string "region:eu-west-1" \
  --query "Resources[].ResourceType" --output text | tr '\t' '\n' | sort | uniq -c | sort -rn | head

Warning

search returns at most the first 1,000 results for a query. Check Count.Complete: if it's false, the list is truncated. Narrow the query by Region, service or account, or use list-resources with filters, and don't treat a truncated list as a full inventory.

aws resource-explorer-2 search --region $HOME_REGION --query-string "service:ec2" \
  --query "Count"

List the resource types the index supports:

aws resource-explorer-2 list-supported-resource-types --region $HOME_REGION \
  --query "ResourceTypes[].ResourceType" --output text | tr '\t' '\n' | grep '^rds'

Troubleshooting

Symptom Cause Fix
search fails with an unauthorized or missing view error No default view in that Region, or no permission on the view Run associate-default-view, or pass --view-arn. Grant resource-explorer-2:Search and GetView
Only the home Region shows results Other Regions have no index, or replication is still running Run list-indexes. Wait a few hours after promoting the aggregator
Tag filters return nothing View created without Name=tags Run update-view --included-properties Name=tags
A new resource doesn't appear Index updates are not instant Wait and search again. Confirm with the service's describe-* call
Resource type missing Type not supported Check list-supported-resource-types, or use AWS Config
Organization view misses accounts Member accounts have no indexes, or setup is incomplete Check list-indexes-for-members from the administrator account
aws resource-explorer-2 list-indexes --region $HOME_REGION \
  --query "Indexes[].[Region,Type]" --output table

Prevent it next time

  • Turn on indexes in every Region of every account when you create the account (Control Tower customisations, StackSets or the organization setup), and not after an incident.
  • Make a tag policy and a weekly -tag.key:Owner search part of cost governance. Send the results to resource owners.
  • Give on-call engineers read access to the organization view, so "who owns this ARN?" takes seconds during an incident.
  • Remember the 1,000-result cap. For full audits and exports, use AWS Config advanced queries, or page through list-resources.