add ecr life cycle

This commit is contained in:
Jun-te Kim 2025-07-18 16:31:51 +00:00
parent eed6f6207b
commit bf390122fa

View file

@ -24,3 +24,27 @@ resource "aws_ecr_repository_policy" "extractor_loader_ecr_access" {
})
}
# ECR lifecycle policy to delete tagged images older than 14 days
resource "aws_ecr_lifecycle_policy" "extractor_loader_lifecycle" {
repository = aws_ecr_repository.extractor_and_loader.name
policy = jsonencode({
rules = [
{
rulePriority = 1
description = "Delete tagged images older than 14 days"
selection = {
tagStatus = "tagged"
countType = "sinceImagePushed"
countUnit = "days"
countNumber = 14
tagPrefixList = [""] # Matches all tagged images
}
action = {
type = "expire"
}
}
]
})
}