Build ECR image lifecycle policies for age, count, and tag patterns.
Last verified: May 2026
Output will appear here...The ECR Lifecycle Policy Builder helps you create lifecycle policies for Amazon Elastic Container Registry repositories. ECR lifecycle policies automatically clean up old or unused container images based on rules you define, such as image age, count, or tag status. This tool provides a visual interface for building these rules with proper priority ordering and tag pattern matching, then generates the JSON policy you can apply to your repository.
Your platform team's ECR storage bill hit $180/month across 30 repositories. You audit with the builder and create a standard policy: priority 1 = 'keep last 10 production-tagged images', priority 2 = 'expire untagged images >7 days old', priority 3 = 'expire dev-tagged images >30 days old'. Apply across all 30 repos via Terraform. Storage drops from 1.8 TB to 240 GB within a week. New monthly bill: $24. Annual savings: ~$1,900.
ECR storage costs $0.10/GB/month — sounds tiny until you have a 500-image repository accumulated over 2 years × 200 MB/image = 100 GB = $10/month for that ONE repo. Multiply across dozens of repos and you're paying $200-500/month for images nobody uses. Lifecycle policies pay for themselves in weeks.
Rule priority matters and is non-obvious. Higher numerical priority = evaluated FIRST (opposite of what you might expect). When deletion rules conflict (e.g., 'keep last 10' and 'delete >30 days old'), the higher-priority rule wins. Plan your priority order carefully — ECR will silently apply only the first matching rule per image.
ECR lifecycle policies don't delete images that are CURRENTLY referenced by a running ECS service or Lambda function. This is mostly a safety feature, but it also means a long-running production deployment can keep an old image alive indefinitely. Always verify that 'kept' images aren't actually orphaned production references.
The builder constructs an ECR lifecycle policy JSON document with rules ordered by priority, each containing a description, a selection (matches by tag status, tag prefix, image age, or image count), and an action (currently only 'expire'). It validates that priorities are unique and outputs the JSON ready for `aws ecr put-lifecycle-policy` or aws_ecr_lifecycle_policy in Terraform.
Was this tool helpful?
Disclaimer: This tool runs entirely in your browser. No data is sent to our servers. Always verify outputs before using them in production. AWS, Azure, and GCP are trademarks of their respective owners.