Skip to content

[ECR] [request]: Support lifecycle policy for image deletion not just transitioning to archiveΒ #2728

@Rylon

Description

@Rylon

Community Note

  • Please vote on this issue by adding a πŸ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Tell us about your request

We'd like to be able to use a standard lifecycle policy to delete images from an ECR repository pull-through cache when they aren't pulled for a number of days, in order to prevent excessive storage growth. Since the primary copy will still exist, it's not a big deal if we clean up the cached images more aggressively.

Which service(s) is this request for?

ECR

Tell us about the problem you're trying to solve. What are you trying to do, and why is it hard?

We tried to use a standard lifecycle policy to do this, and we used the AWS Console to choose the "Expire on last pulled" from the "Lifecycle policy examples" drop-down menu. It generates the following policy JSON:

{
    "rules": [
        {
            "rulePriority": 1,
            "description": "Expire images tagged 'v.*.*' not pulled in the last 90 days",
            "selection": {
                "tagStatus": "tagged", 
                "tagPatternList": ["v.*.*"],
                "countType": "sinceImagePulled", 
                "countUnit": "days",
                "countNumber": 90
            },
            "action": {
                "type": "expire"
            }
        }
    ]
}

But when we try to save this, it is rejected:

API error
Invalid parameter at 'LifecyclePolicyText' failed to satisfy constraint: 'Lifecycle policy validation failure: SINCE_IMAGE_PULLED CountType can only be used with TRANSITION ActionType'

It seems it's not possible to directly delete the images in the policy? It is possible to transition them to the archive storage type, and then delete them from there, however ECR enforces a 90 day minimum storage period for archived images, so even if we created a policy which archived after 7 days, we'd still be billed for 90 days, which is undesirable.

Are you currently working around this issue?

We currently don't have a solution for this, and will be investigating options in the new year.

Additional context

N/A

Attachments

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    ECRAmazon Elastic Container RegistryProposedCommunity submitted issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions