From e069f5d12983fa6e8789ad8a101ab384da8f5341 Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Mon, 2 Feb 2026 23:30:45 +0000 Subject: [PATCH] go back to the old one --- infrastructure/terraform/modules/ecr/main.tf | 33 ++------------------ 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/infrastructure/terraform/modules/ecr/main.tf b/infrastructure/terraform/modules/ecr/main.tf index ee4cac11..468ef3d2 100644 --- a/infrastructure/terraform/modules/ecr/main.tf +++ b/infrastructure/terraform/modules/ecr/main.tf @@ -1,6 +1,7 @@ resource "aws_ecr_repository" "my_repository" { name = "${var.ecr_name}" image_tag_mutability = "MUTABLE" + # Allows overwriting image tags, change to IMMUTABLE if you want to prevent overwriting image_scanning_configuration { scan_on_push = true @@ -12,38 +13,10 @@ resource "aws_ecr_lifecycle_policy" "my_repository_policy" { policy = jsonencode({ rules = [ - # 1️⃣ Keep important env tags forever { rulePriority = 1 - description = "Keep prod, main, dev images forever" - selection = { - tagStatus = "tagged" - tagPrefixList = ["prod", "main", "dev"] - } - action = { - type = "retain" - } - }, - - # 2️⃣ Aggressively expire untagged images - { - rulePriority = 2 - description = "Expire untagged images" - selection = { - tagStatus = "untagged" - countType = "imageCountMoreThan" - countNumber = 1 - } - action = { - type = "expire" - } - }, - - # 3️⃣ Rotate everything else - { - rulePriority = 3 description = "Retain only the last 10 images" - selection = { + selection = { tagStatus = "any" countType = "imageCountMoreThan" countNumber = 10 @@ -54,4 +27,4 @@ resource "aws_ecr_lifecycle_policy" "my_repository_policy" { } ] }) -} +} \ No newline at end of file