I am trying to describe AMI from AWS CLI by ImageId, and I used below code.
aws ec2 describe-images --profile xxxxxxxxxx \
--filter Name=tag:Name,Values=Backup*some-string* \
--query "Images[*].[Tags[?Key=='Name'].Value[]|[0],ImageId]"
output :
[
[
"Backup-20191215T112530Z-utc-some-string",
"ami-004"
],
[
"Backup-20191219T714631Z-utc-some-string",
"ami-002"
],
[
"Backup-20191208T145534Z-utc-some-string",
"ami-001"
],
[
"Backup-20191222T157530Z-utc-some-string",
"ami-003"
],
[
"Backup-20191221T134530Z-utc-some-string",
"ami-005"
]
]
I found sort_by method of JMESPath would be a solution but it is diffficult to understand.