Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Script or api to provide the ami-id of the latest amazon-ecs-optimized image

I ran into a requirement where I need get the EC2 ami id of the latest amazon-ecs-optimized image of a specific region. Is there any script or api that is available to pick the ami-id, that they provide while creating a new cluster?

Create Cluster page in AWS Console

So that once they update the console with the latest ami, I need not update my scripts.

like image 317
Neeraj Avatar asked Apr 08 '17 17:04

Neeraj


1 Answers

combining the answer from @romaninsh and @Derek

aws ssm get-parameters --names /aws/service/ecs/optimized-ami/amazon-linux/recommended | \
    jq -r .Parameters[].Value | jq -r .image_id
like image 152
qrkourier Avatar answered Sep 28 '22 00:09

qrkourier