When it comes to managing cloud infrastructure, clarity is paramount. Security officers, managers, and other stakeholders often seek a high-level summary of instances within their hosting environment. While visualizations can be enlightening, there are times when raw data is simply more useful. Enter the AWS Command Line Interface (CLI) — a powerful tool that streamlines this process with the describe-instances command.
The basic command is straightforward and well-documented. To retrieve a comprehensive overview of your EC2 instances, you can run:
aws ec2 describe-instances
This command will return a treasure trove of information in JSON format. However, if your goal is to zero in on specific details—say, the IP addresses—you’ll want to refine your query.
To list only the Instance IDs along with their public and private IP addresses, use the following command:
aws ec2 describe-instances \
--query "Reservations[*].Instances[*].[InstanceId,PublicIpAddress,PrivateIpAddress]" \
--output=table
This will yield a neatly formatted table that highlights the essential information:

But the AWS CLI’s power doesn’t stop there. If you want to include additional fields—like instance names—you can adjust your command accordingly:
aws ec2 describe-instances \
--query "Reservations[*].Instances[*].[InstanceId,PublicIpAddress,PrivateIpAddress,Tags[?Key=='Name'].Value[]]" \
--output=text
With this command, you’re not just pulling data; you’re creating a customized view that speaks directly to your needs. The query option is incredibly flexible, allowing for a range of applications beyond what we’ve discussed here.
In essence, the AWS CLI can serve as a bridge between complex data and actionable insights. By mastering these commands, you empower yourself to make informed decisions swiftly — a crucial capability in today’s fast-paced digital landscape.
So, the next time you’re tasked with providing an overview of your EC2 instances, remember: clarity in your command leads to clarity in your understanding. Happy scripting!