I'm currently creating a python script in order to create an adapter to AWS ECR using AWS CLI. I have a staging environment with a versioned test container in version 1.0.0. Now I try to retag it using the following control flow:
- Save the manifest.json of the versioned container:
aws ecr batch-get-image --repository-name staging/test --image-ids imageTag=1.0.0 --output text
(the json output of the aws cli is buggy and cannot be parsed in a robust way) - Delete the old "latest" tag:
aws ecr batch-delete-image --repository-name staging/test --image-ids imageTag=latest
- Use the image digest and the manifest json to re-tag the image:
aws ecr put-image --repository-name staging/test --image-tag latest --image-manifest file://manifest.json --image-digest sha256:foobar
The problem: The ECR throws an exception describing that the image digest does differ. But there is no 'latest' image - it was untagged. So I tried to tag the image to a non-existing version '2.0.0' and one time without the digest. The ECR tags the image and calculates a new image digest - which seems to be the core problem. Sense - it does not make any.