Skip to content

Instantly share code, notes, and snippets.

@krish143434
Created February 21, 2020 20:03
Show Gist options
  • Select an option

  • Save krish143434/877668b02d5dfdb7a0f38cc513cbc8f0 to your computer and use it in GitHub Desktop.

Select an option

Save krish143434/877668b02d5dfdb7a0f38cc513cbc8f0 to your computer and use it in GitHub Desktop.
Following script will check ecr and get the Imagetag in json format, please have jason parser installed in your OS, if not availabile.
#!/usr/bin/env bash
# Example:
# ./find-ecr-image.sh foo/bar mytag
if [ $# -lt 2 ]; then
echo "Usage: $( basename $0 ) <repository-name> <image-tag>"
exit 1
fi
IMAGE_META="$( aws ecr describe-images --repository-name=$1 --image-ids=imageTag=$2 2> /dev/null )"
echo $IMAGE_META
if [ $? -eq 0 ]; then
IMAGE_TAGS="$( echo ${IMAGE_META} | jq '.imageDetails[0].imageTags[0]' -r )"
echo "$1:$2 found"
else
echo "$1:$2 not found"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment