go back to the old one

This commit is contained in:
Jun-te Kim 2026-02-02 23:30:45 +00:00
parent 9208b3eda4
commit e069f5d129

View file

@ -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" {
}
]
})
}
}