Skip to content

Instantly share code, notes, and snippets.

@filipeandre
Forked from nathanieltalbot/check_tag_exists.py
Created August 5, 2022 12:47
Show Gist options
  • Save filipeandre/c32cd5b2850aa1b0f611ab1e26efe801 to your computer and use it in GitHub Desktop.
Save filipeandre/c32cd5b2850aa1b0f611ab1e26efe801 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
# 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