β Repository β π Compliance Engine β π CloudAware β π AWS β π ECR
π‘οΈ AWS ECR Repository Lifecycle Policy is not configuredπ’
- Contextual name: π‘οΈ Repository Lifecycle Policy is not configuredπ’
- ID:
/ce/ca/aws/ecr/repository-lifecycle
- Tags:
- π’ Policy with categories
- π’ Policy with type
- π’ Production policy
- Policy Type:
COMPLIANCE_POLICY
- Policy Categories:
COST
,RELIABILITY
Logicβ
- π§ prod.logic.yamlπ’
Similar Policiesβ
- AWS Security Hub: [ECR.3] ECR repositories should have at least one lifecycle policy configured
- Internal:
dec-x-9a0607d9
Similar Internal Rulesβ
Rule | Policies | Flags |
---|---|---|
βοΈ dec-x-9a0607d9 | 1 |
Descriptionβ
Descriptionβ
This policy identifies AWS ECR Repositories that do not have a lifecycle policy configured. A lifecycle policy is a set of rules that automates the management of images in a repository, helping to clean up old or unused images.
Rationaleβ
Configuring a lifecycle policy is a best practice for managing container images in ECR. It helps to:
- Reduce Storage Costs: Automatically removes old or untagged images, preventing them from accumulating and incurring unnecessary storage charges.
- Improve Repository Hygiene: Keeps repositories clean and makes it easier to find relevant images.
- Avoid Hitting Service Quotas: Prevents reaching the maximum number of images allowed per repository.
Auditβ
This policy flags an AWS ECR Repository as
INCOMPLIANT
if itsLifecycle Policy Text JSON
is empty.
Remediationβ
Remediationβ
Configure Lifecycle Policyβ
Create and apply a lifecycle policy to your Amazon ECR repository. A lifecycle policy contains one or more rules that define the cleanup actions for the images in your repository.
From AWS CLIβ
Create a JSON file named
{{lifecycle-policy}}.json
with the rules for your policy. For example:{
"rules": [
{
"rulePriority": 1,
"description": "Expire images older than 14 days",
"selection": {
"tagStatus": "untagged",
"countType": "sinceImagePushed",
"countUnit": "days",
"countNumber": 14
},
"action": {
"type": "expire"
}
}
]
}Apply the lifecycle policy to your repository:
aws ecr put-lifecycle-policy \
--repository-name {{repository-name}} \
--lifecycle-policy-text file://{{lifecycle-policy}}.json... see more