Add this AWS ECR Lifecycle Policy for cost reduction
In AWS ECR all pushed images are stored in the ECR. It does not matter it is currently used or not. But AWS charge you for storing these images. In order to prevent this you can use a lifecycle policy to delete the images which are outdated.
To set this policy first go to AWS => ECR => Repositories
Then select a repository, go to => Actions => Lifecycle policies
Click “Create Rule”
Here you can set a policy to delete the images according to the match criteria that you have given. In the example above I have set a policy to delete any image in the ecr which is 10 days or older.
When you hit save within 5 minutes you will see the old images are gone and the policy is working pretty well.