DEV Community

Cover image for AWS CLI EC2 Describe Instances and more!
Luiz Campedelli
Luiz Campedelli

Posted on

AWS CLI EC2 Describe Instances and more!

If i need to get all the Linux instances tag names, ids, ami, keys...:

aws ec2 describe-instances \
    --filters "Name=platform-details,Values=Linux/UNIX,Ubuntu Pro" \
    --query 'Reservations[*].Instances[*].[InstanceId, State.Name, PlatformDetails, ImageId, KeyName, Tags[?Key==`Name`].Value | [0]]' \
    --output table
Enter fullscreen mode Exit fullscreen mode

To get the Linux EC2 operational system details, for update purposes:

aws ssm describe-instance-information \
    --query 'InstanceInformationList[*].[InstanceId, PlatformName, PlatformVersion, PlatformType]' \
    --output table
Enter fullscreen mode Exit fullscreen mode

If you need to do a fine check, to see an instance that doesn't appear in the previous search, it can happen sometimes:

aws ssm describe-instance-information \
    --filters "Key=InstanceIds,Values=<**Instance ID**>" \
    --query 'InstanceInformationList[0].[InstanceId, PlatformName, PlatformVersion]' \
    --output table
Enter fullscreen mode Exit fullscreen mode

The documentation is:

aws-describe-instances

For Windows EC2, checkout the documentation, some minor changes can be applie to the cli commands and get the same results.

Top comments (0)