> ## Documentation Index
> Fetch the complete documentation index at: https://help.nops.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Add Lifecycle Policy to ECR Repository

> Add a lifecycle policy to ECR repositories that keep every image forever.

Without a lifecycle policy, an ECR repository keeps every image it has ever received, and you pay for all of them. nOps finds repositories that have kept growing for 90 days without anything being deleted, and estimates the saving from expiring untagged images and images older than 90 days.

| | |
| - | - |
| **Cloud** | AWS |
| **Category** | Storage |
| **Service** | Amazon ECR |
| **Action** | Modify |
| **Effort** | Low |
| **Restart needed** | No |
| **Can be rolled back** | No |
| **Analysis window** | Last 90 days |
| **Source** | nOps |

## Why it matters

CI pipelines push new images on every build, so repositories grow steadily. Old images are rarely pulled again but are billed every month.

## How nOps finds it

nOps reads the daily storage of each repository over the last 90 days. A repository is flagged when it grew by at least 5%, never shrank by more than 3% on any day, and held at least 1 GB 90 days ago. Because nothing was deleted, the storage it already had 90 days ago is treated as images at least 90 days old. The saving is that share of the repository's monthly cost, at your billed rate.

## Before you start

Know which image tags your services, deployments and rollback plans rely on.

## How to implement

1. List the tags your services deploy from and any images you must keep for rollback or compliance.
2. In the ECR console, open the repository and choose **Lifecycle policy → Create rule**.
3. Add a rule that expires untagged images, and a rule that expires images older than 90 days while keeping the tags you deploy (for example, by tag prefix).
4. Use **Preview** to see which images the policy would remove before saving it.

## Risks and considerations

* Expired images are deleted permanently. Preview the policy and keep anything you might need to roll back to.
* Images share layers, so the real saving can be lower than the estimate when old images share layers with current ones.

## FAQs

> [accordion] Why 90 days?
>
> It is the window nOps measures. You can choose a longer or shorter age, or keep a set number of images instead.

## Related

* [Supported recommendations](https://help.nops.io/inform/supported-recommendations.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.