amazon web services - Get the latest Windows 2012R2 base AMI id using aws cli? -


is there way latest windows 2012r2 base ami id using aws cli?

something get-ec2imagebyname -names windows_2012r2_base in powershell. want use in linux.

i have tried fetching ami id aws ec2 describe-images --owners amazon --filters "name=name,values=windows_server-2012-r2_rtm-english-64bit-base-*" feels hack. there better way in powershell?

the "hack" described correct way retrieve these in aws cli. matter of fact, powershell tools' get-ec2imagebyname behind scenes; maps raw ami name (exposed showfilter parameter) pre-defined name pattern, exposed allavailable parameter.

you can see listing showfilter parameter; first result matches name value you've listed:

c:/ > get-ec2imagebyname -showfilters  windows_server-2012-r2_rtm-english-64bit-base* windows_server-2012-r2_rtm-english-64bit-sql_2014_sp1_express* windows_server-2012-r2_rtm-english-64bit-sql_2014_sp1_standard* windows_server-2012-r2_rtm-english-64bit-sql_2014_sp1_web* windows_server-2012-rtm-english-64bit-base* ... 

to latest windows 2012 r2 ami id aws cli, sort query creationdate , limit last result.

example:

aws ec2 describe-images \     --owners 'amazon' \     --filters 'name=name,values=windows_server-2012-r2_rtm-english-64bit-base*' \     --query 'sort_by(images, &creationdate)[-1].[imageid]' \     --output 'text' 

output:

ami-11e84107 

further reading


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -