Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find OS of an EC2 instance using AWS CLI

How can you find out the OS running on an EC2 instance using AWS CLI.

The ec2 describe-instance command spits out a lot of information , but there is nothing indicating the OS .

I also tried ec2 describe-images on a specific image. Again, there doesn't seem to be any indication of OS.

Help..?

like image 450
ivarrian Avatar asked Apr 09 '14 00:04

ivarrian


2 Answers

Here's a quick way to list the Platform field, which at least distinguishes between Windows and Linux:

aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId,Platform]' --output text
i-78b4ef47  windows
i-b8ae3386  windows
i-9d3611a2  None
i-1c57c651  windows
i-a241ec91  None
i-7d26b630  None
like image 76
John Rotenstein Avatar answered Nov 15 '22 07:11

John Rotenstein


Try this command:

aws ec2 describe-images --image-ids $(aws ec2 describe-instances --instance-ids i-xxxxxxxxxxxxx --query 'Reservations[0].Instances[0].ImageId' --output text) --query 'Images[0].Name'

$() part gets the ImageId using InstanceId.

like image 24
riverfall Avatar answered Nov 15 '22 07:11

riverfall