From d8d359879972b4fe7f8c77981c7a5c50b70433d7 Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Mon, 21 Jul 2025 09:29:58 +0000 Subject: [PATCH] terraform polciy --- .../lambda/lambda_example/docker/ecr.tf | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) 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 +}