Skip to content

Instantly share code, notes, and snippets.

@caffeinetiger
Last active April 18, 2022 18:16
Show Gist options
  • Select an option

  • Save caffeinetiger/49f406a95bbe13badc764c2a80e17459 to your computer and use it in GitHub Desktop.

Select an option

Save caffeinetiger/49f406a95bbe13badc764c2a80e17459 to your computer and use it in GitHub Desktop.
There is no user friendly way to retag an image in the AWS ECR Web Console. You need to use AWS CLI commands to accomplish this. - [Official AWS Documentation](https://docs.aws.amazon.com/AmazonECR/latest/userguide/image-retag.html) - [Stackoverflow
#!/bin/bash
# Get image manifest by tag
MANIFEST=$(aws ecr batch-get-image --repository-name amazonlinux --image-ids imageTag=latest --output json | jq --raw-output '.images[0].imageManifest')
# Or
# Get image manifest by digest (this is found on the ECR repo page in the AWS Web Console)
MANIFEST=$(aws ecr batch-get-image --repository-name amazonlinux --image-ids imageDigest=sha256:8e080763aa56a2d509f9614613019ff0d9fe9cfd651b2efdb8961356c9ea6e26 --query 'images[].imageManifest' --output text)
# Update image with new tag
aws ecr put-image --repository-name amazonlinux --image-tag previous.2018 --image-manifest "$MANIFEST"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment