Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Only Keep last 4 images on ECR [closed]

Tags:

amazon-ecr

Hello guys as we all know that there's a limit on storing images on ECR and that's why we want to keep only last 4 images on ECR. Any leads would be appreciated.


1 Answers

You can use ECR Lifecycle Policies to delete all but the last 4 images with the following policy:

{
    "rules": [
        {
            "rulePriority": 1,
            "description": "Rule 1",
            "selection": {
                "tagStatus": "any",
                "countType": "imageCountMoreThan",
                "countNumber": 4
            },
            "action": {
                "type": "expire"
            }
        }
    ]
}

like image 161
Richard Nguyen Avatar answered Sep 21 '25 15:09

Richard Nguyen