aws / aws/containers-roadmap

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

Open
#2,728 1 comment 157 reactions 0 assignees View on GitHub
ECR Proposed
Dominant language
Shell
Stars
5.4k
Forks
334
PR merge metrics
No merged PRs in 30d

Description

### Community Note

* Please vote on this issue by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) 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

Contributor guide

Open the contributing guide

Research direction

No repository files, tests, or implementation entry points are identified in the issue. Start by reviewing the reported AWS ECR lifecycle-policy validation and pull-through-cache behavior; the work is done when a policy using SINCE_IMAGE_PULLED with EXPIRE can delete eligible cached images without requiring archive storage.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws
Domain
cloud
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.