Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get the most recent semver tag for an ECR repo
import pprint
import boto3
import sys
repo_name = sys.argv[1]
print(repo_name)
client = boto3.client('ecr')
response = client.list_images(
repositoryName=repo_name,
filter={
'tagStatus': 'TAGGED'
}
)
images = response['imageIds']
def splitter(image):
tag = image['imageTag']
try:
return tuple(map(int, tag.split('.')))
except:
return (0,0,0)
sorted = images.sort(key=splitter,reverse=True )
print(images[0]['imageTag'])
@talolard

This comment has been minimized.

Copy link
Owner

talolard commented Jun 5, 2018

Use this to know which tag of an image to deploy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment