shantanuo
shantanuo

Reputation: 32336

Finding the full name of windows server

This command lists hundreds of windows servers. How do I select the most popular ones those are displayed on web console while I create a new instance?

# aws ec2 describe-images --owners amazon --filters "Name=name,Values=Windows_Server*" --query 'sort_by(Images, &CreationDate)[].Name'
[
    "Windows_Server-2016-English-Full-ECS_Optimized-2017.11.24",
    "Windows_Server-2016-English-Full-ECS_Optimized-2018.01.10",
    "Windows_Server-2016-English-Full-ECS_Optimized-2018.02.21",
    "Windows_Server-2016-English-Full-ECS_Optimized-2018.03.26",
    "Windows_Server-2016-English-Nano-Base-2018.04.11",
...
...
]

I am looking for the full name and not just the ami-id.

For e.g. which one of the above is "ami-04ca2d0801450d495"?

Upvotes: 0

Views: 313

Answers (2)

krishna_mee2004
krishna_mee2004

Reputation: 7366

The DescribeImages API call returns the name of the AMI along with the rest of the info. To extract just the name of the AMI, you can run the following command:

aws ec2 describe-images --image-ids $IMAGE_ID \
    --output text --query 'Images[*].Name'

Details about the describe-images command can be found here.

Upvotes: 1

shantanuo
shantanuo

Reputation: 32336

This command will return the full name of the given ami ID

 aws ssm get-parameters-by-path --path "/aws/service/ami-windows-latest" --region us-east-1 | grep -C3  '04ca2d0801450d495'

Upvotes: 0

Related Questions