ECR repositories should have at least one lifecycle policy configured
Identifier
ecr-configure-private-lifecycle-policy
Category
Identify > Resource configuration
Description
This control checks whether Amazon Elastic Container Registry (ECR) private repositories have lifecycle policies configured. Lifecycle policies help manage image storage by automatically expiring unused or old container images. This reduces costs, improves organization, and lowers the risk of deploying outdated images. The check verifies that a aws_ecr_lifecycle_policy resource is associated with each aws_ecr_repository.
Non Compliant Example
| Terraform | |
|---|---|
Remediation
To fix this violation, define a lifecycle policy using the aws_ecr_lifecycle_policy resource. For example, retain only the 10 most recent images tagged with "prod" and expire untagged images after 14 days: