Created
November 4, 2019 19:34
-
-
Save nathanieltalbot/784d49d2418c0fb8b656f1959d0f4624 to your computer and use it in GitHub Desktop.
A simple Python function to check if an image tag exists in an ECR repo using boto3
This file contains 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
# Checks if an image tag exists in the repo | |
def check_tag_exists(tag, repo): | |
ecr_client = boto3.client('ecr', region_name='us-east-1') | |
response = ecr_client.describe_images(repositoryName=repo, filter={'tagStatus': 'TAGGED'}) | |
for i in response['imageDetails']: | |
if tag in i['imageTags']: | |
return True | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This does not handle pagination, if there are more than 100 images in your repo this might fail