Skip to content

Instantly share code, notes, and snippets.

@talolard
Created June 5, 2018 19:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talolard/5fde6e5c036e6fffbf588ddbe0100410 to your computer and use it in GitHub Desktop.
Save talolard/5fde6e5c036e6fffbf588ddbe0100410 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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