Forked from rshettynj/gist:7731cc37d88446eda570d0669899549f
          
        
    
          Created
          January 17, 2024 19:07 
        
      - 
      
 - 
        
Save epankur/574665755c6c208309b65a159f5b6e05 to your computer and use it in GitHub Desktop.  
    How to add new tags and remove unwanted tag from AWS ECR Image?
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | //Get the current manifest of the ECR image ecrimage-800 | |
| MANIFEST=$(aws ecr batch-get-image --repository-name ecrimage-800 --image-ids imageTag=latest --query 'images[].imageManifest' --output text) | |
| echo $MANIFEST | jq '.' | |
| //Push the tag called newtag along with image manifest. | |
| aws ecr put-image --repository-name ecrimage-800 --image-tag newtag --image-manifest "$MANIFEST" | |
| //Now ecrimage-800 will have two tags, "latest" and "newtag". You are ready to remove "latest" tag if you like. | |
| aws ecr batch-delete-image --repository-name ecrimage-800 --image-ids imageTag=latest | |
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment