AWS ECR error – RepositoryNotFoundException

The Error

The AWS ECR cli does not switch regions, even when requesting a different get-login.


 aws ecr get-login –-registry-ids 191499206908  --region us-west-2
 // do login

 aws ecr describe-repositories
 // returns results of us-west-1, even though we signed in using us-west-2
 
 aws ecr  batch-get-image --repository-name  --image-ids imageTag=latest

 An error occurred (RepositoryNotFoundException) when calling the BatchGetImage operation: The repository with name '' does not exist in the registry with id ''

The Fix

The amazon docs for ecr are not listing the –region flag, but it works. http://docs.aws.amazon.com/cli/latest/reference/ecr/describe-repositories.html. You can add it to the ecr commands that you need.


 aws ecr describe-repositories --region us-west-2

Here’s how I encountered the error, and other operations the error occurs in. Trying to retag an image, http://docs.aws.amazon.com/AmazonECR/latest/userguide/retag-aws-cli.html.


$ MY_MANIFEST=$(aws ecr batch-get-image --repository-name amazonlinux --image-ids imageTag=latest --query images[].imageManifest --output text)

An error occurred (RepositoryNotFoundException) when calling the BatchGetImage operation: The repository with name '' does not exist in the registry with id ''

aws ecr  batch-get-image --repository-name  --image-ids imageTag=latest

An error occurred (RepositoryNotFoundException) when calling the BatchGetImage operation: The repository with name '' does not exist in the registry with id ''

// the fixed version
aws ecr  batch-get-image --repository-name  --image-ids imageTag=latest --region us-west-2
Share this:

Leave a comment