Using AWS CLI, and jq if needed, I\'m trying to get the tag of the newest image in a particular repo.
Let\'s call the repo foo
, and sa
List latest 3 images
aws ecr describe-images --repository-name gvh \
--query 'sort_by(imageDetails,& imagePushedAt)[*].imageTags[0]' --output yaml \
| tail -n 3 | awk -F'- ' '{print $2}'
Skip latest 3 images
aws ecr describe-images --repository-name gvh \
--query 'sort_by(imageDetails,& imagePushedAt)[*].imageTags[0]' --output yaml \
| head -n -3 | awk -F'- ' '{print $2}'
Number '3' can be generalized in either head or tail command based on user requirement