How to find which AWS region an EC2 instance (or anything else) is in
Updated · 3 min read
An alert, a bill or a colleague hands you i-0123456789abcdef0, and pasting it into the EC2 console finds nothing. That's because the console only searches the region you're in, and an instance ID doesn't say which region it belongs to. The same goes for volumes, security groups, IP addresses and most other things in AWS.
In the AWS console
- EC2 Global View. Type "EC2 Global View" into the search bar at the top of the console. The Global search tab searches EC2 resources (instances, volumes, VPCs, security groups and more) in every region at once, so paste the ID there. The overview tab also counts resources per region, which is a quick way to spot a server running somewhere you'd forgotten about.
- Resource Explorer covers other services too, once it's set up. On your first visit choose Quick setup and pick a region for the "aggregator index". It takes a while to index everything; after that, search by name or ID, or with filters like
resourcetype:ec2:instanceorregion:eu-west-1. - Bills. If the question is "where is the thing I'm paying for?", the Bills page breaks each service's charges down by region. See how to find out what's costing money.
With the AWS CLI
Look for an instance in every region your account has turned on:
id=i-0123456789abcdef0
for region in $(aws ec2 describe-regions --query 'Regions[].RegionName' --output text); do
aws ec2 describe-instances --region "$region" \
--filters "Name=instance-id,Values=$id" \
--query 'Reservations[].Instances[].[InstanceId, State.Name, Placement.AvailabilityZone]' \
--output text
doneIt prints the instance's state and its availability zone, like eu-west-1b. The region is the zone without its last letter. Using a filter rather than --instance-ids means regions without the instance return nothing, rather than an error each.
Other filters work the same way:
- Public IP address:
--filters "Name=ip-address,Values=203.0.113.25" - Private IP address:
--filters "Name=private-ip-address,Values=10.0.1.17" - The name shown in the console (the
Nametag):--filters "Name=tag:Name,Values=web-1"
For anything that isn't EC2, and once Resource Explorer is set up, one command searches every region. Run it in the region you chose for the aggregator index:
aws resource-explorer-2 search --region us-east-1 \
--query-string "resourcetype:ec2:instance" \
--query 'Resources[].[Region, Arn]' --output textSwap the query string for whatever you're after, like a name, or resourcetype:rds:db for databases. A search returns at most 1,000 results, so narrow it with filters if you have more.
Or in Cloud GUI
Cloud GUI looks in every region at once and shows the results in one list: your servers (EC2), files (S3), functions (Lambda) and log groups (CloudWatch). The Servers page lists every EC2 instance in every region turned on in your account, with its region, state, type and IP address, and its filter box matches names and instance IDs, so pasting i-0123456789abcdef0 finds it straight away. On Pro, with editing turned on, a server's page can also start, stop and reboot it (only servers tagged cloudgui:editable = true, if your editing role is limited to tagged servers). For the same idea applied to functions, see how to list every Lambda function across regions.