How to see all running Amazon EC2 instances across all regions?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Amazon Elastic Compute Cloud (EC2) is a core part of Amazon Web Services (AWS) that offers resizable compute capacity in the cloud. Managing and monitoring EC2 instances is a routine task, especially in extensive AWS environments with multiple accounts and instances spread across different regions. This guide explores methods to view all running EC2 instances across all AWS regions, providing technical steps and examples for clarity.
Understanding the Problem
By default, the AWS Management Console displays EC2 instances only within the selected region. However, large organizations often have instances distributed across multiple regions for redundancy, localization, or performance optimization. Therefore, it's essential to have a centralized way to view all instances to maintain operational oversight and optimize costs.
Method 1: AWS CLI
The AWS Command Line Interface (CLI) is a powerful tool for interacting with AWS services from your terminal. It can be used to list EC2 instances across all regions.
Step-by-Step Process
- Install AWS CLI: Make sure you have the AWS CLI installed. You can download it from the AWS CLI official page.
- Configure AWS CLI: Before using the AWS CLI, configure it with your AWS account credentials:
You will be prompted to enter your AWS Access Key ID, Secret Access Key, default region, and output format.
- List Available Regions: Use the following command to list all AWS regions:
- List Instances in All Regions: Iterate over each region and retrieve its EC2 instances. Here's a shell script example that demonstrates this process:
Example Output
This command provides a tabular output comprising instance IDs, types, states, instance names, and public IP addresses.
Method 2: AWS Management Console
- Access EC2 Global View: AWS provides a unified EC2 global view feature that enables you to view instances across regions directly from the AWS Management Console.
- Use AWS Resource Groups: Create a resource group in the AWS Management Console to filter resources (like EC2 instances) across multiple regions.
- Enable Organization View: For organizations using AWS Organizations, you can opt for consolidated billing and use the management account to view resources across all member accounts and regions.
Method 3: AWS SDKs
AWS Software Development Kits (SDKs) for languages like Python (Boto3), Java, and Node.js provide programmatic access to AWS. This can be particularly useful for automated reports or integrations into other applications.
Python Example
Here's how you might use Boto3, the AWS SDK for Python, to list instances:
Key Considerations
- IAM Permissions: Ensure the IAM user or role has adequate permissions to list EC2 instances using AWS CLI, SDK, or console.
- Cost and Resource Management: Seeing all instances aids in better cost management and operational adjustments.
- Cross-Account Visibility: For a complete organizational view, include cross-account capabilities using AWS Organizations or IAM roles with assume role functionalities.
Summary Table
| Method | Tools/Commands | Features |
| AWS CLI | aws ec2 describe-instances | Direct, programmatic CLI-based access |
| AWS Management Console | EC2 Global View | User-friendly, no coding required |
| AWS SDKs | Boto3 for Python, AWS SDK for Java/Node.js | Integrations into applications |
These methods collectively offer comprehensive coverage for monitoring and managing AWS EC2 instances across multiple regions and accounts. Understanding and applying them effectively enhances operational efficiency in AWS environments.
Related reading
- How to send batches of million push notifications using Amazon Simple Notification Service SNS
- How to send email to non-verified email address using AWS SES
- how to send emails from amazon EC2?
- How to separate multiple clauses in a DynamoDB Update Expression
- How to see docker image contents
- How to see logs of terminated pods
- How to set a boolean field in Dynamo DB?
- How to set a DynamoDB Map property value, when the map doesn''t exist yet

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.