1
votes

Lets say "foo" is the repository name and I want to call the image which has two tags "boo, boo-0011"

This command displays all the images in the repository:

aws ecr describe-images --repository-name foo --query "sort_by(imageDetails,& imagePushedAt)[ * ].imageTags[ * ]"

From this how do I grep only the one which has a tag "boo"

2
If one of the provided answers solved your question, please consider accepting it. - jarmod

2 Answers

1
votes

You can use --filter tagStatus=xxx but that only allows you to filter on TAGGED or UNTAGGED images, not images with a specific tag.

To find images with a specific tag, say boo, you should be able to use the somewhat inscrutable, but very helpful, jq utility. For example:

aws ecr describe-images \
    --region us-east-1 \
    --repository-name foo \
    --filter tagStatus=TAGGED \
    | jq -c '.imageDetails[] | select([.imageTags[] == "boo"] | any)'
1
votes

Personally I use grep for this

aws ecr describe-images --repository-name foo --query "sort_by(imageDetails,& imagePushedAt)[ * ].imageTags[ * ]" | grep -w 'boo'

-w is the grep command for the whole word matching.