Last active
June 25, 2018 15:42
-
-
Save pahud/aab838a0a3a9db857d822fe1f222683c to your computer and use it in GitHub Desktop.
get latest 3 amazon-ecs-optimized amzn-ami with AWS-CLI and JMESPath Query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ aws --region ap-northeast-1 ec2 describe-images --owner amazon --query 'Images[?Name!=`null`]|[?contains(Name, `ecs-optimized`) == `true`]|[?contains(Name, to_string(`2016`)) == `true`]|[0:3].[Name,ImageId,CreationDate,Description]' --output text | sort -rk1 | |
amzn-ami-2016.03.g-amazon-ecs-optimized ami-058a4964 2016-08-11T22:26:29.000Z Amazon Linux AMI 2016.03.g x86_64 ECS HVM GP2 | |
amzn-ami-2016.03.e-amazon-ecs-optimized ami-2b08f44a 2016-07-11T22:28:39.000Z Amazon Linux AMI 2016.03.e x86_64 ECS HVM GP2 | |
amzn-ami-2016.03.c-amazon-ecs-optimized ami-095dbf68 2016-05-26T23:32:34.000Z Amazon Linux AMI 2016.03.c x86_64 ECS HVM GP2 | |
# or check the page http://docs.aws.amazon.com/AmazonECS/latest/developerguide/launch_container_instance.html for latest AMI ID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment