Batch deleting ECR Images

Ryan Graham
Feb 12, 2021

--

Sometimes you go to delete a CloudFormation stack or destroy some Terraform and the run fails to delete an ECR repo because the repository still contains images.

The following resource(s) failed to delete: [ECRRepository].

Here is a quick and dirty way to empty that repo before you retry your delete. Excuse the ugly python. Its a one-off script not a maintained project. 😉

Invoke it like this: ./ecr_purge.py my-ecr-repo-name

Then go back and press delete on your CloudFormation stack and voilà!

--

--

No responses yet