diff --git a/deployment/lambda/lambda_example/docker/ecr.tf b/deployment/lambda/lambda_example/docker/ecr.tf index 4eb7db4..b6f1967 100644 --- a/deployment/lambda/lambda_example/docker/ecr.tf +++ b/deployment/lambda/lambda_example/docker/ecr.tf @@ -29,21 +29,33 @@ resource "aws_ecr_lifecycle_policy" "extractor_loader_lifecycle" { repository = aws_ecr_repository.lambda_example.name policy = jsonencode({ - rules = [ - { - rulePriority = 1 - description = "Delete tagged images older than 14 days" - selection = { - tagStatus = "tagged" - countType = "sinceImagePushed" - countUnit = "days" - countNumber = 5 - # Removed tagPrefixList + "rules": [ + { + "rulePriority": 1, + "description": "Expire images older than 14 days", + "selection": { + "tagStatus": "untagged", + "countType": "sinceImagePushed", + "countUnit": "days", + "countNumber": 1 + }, + "action": { + "type": "expire" + } + }, + { + "rulePriority": 1, + "description": "Keep last 5 images", + "selection": { + "tagStatus": "tagged", + "tagPrefixList": ["v"], + "countType": "imageCountMoreThan", + "countNumber": 5 + }, + "action": { + "type": "expire" + } } - action = { - type = "expire" - } - } ] }) -} \ No newline at end of file +}