33 lines
No EOL
837 B
HCL
33 lines
No EOL
837 B
HCL
# This ecr works for things deployed by serverless.
|
|
# TODO: unify ecr and container_registry to one
|
|
|
|
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
|
|
}
|
|
}
|
|
|
|
resource "aws_ecr_lifecycle_policy" "my_repository_policy" {
|
|
repository = aws_ecr_repository.my_repository.name
|
|
|
|
policy = jsonencode({
|
|
rules = [
|
|
{
|
|
rulePriority = 1
|
|
description = "Retain only the last 10 images"
|
|
selection = {
|
|
tagStatus = "any"
|
|
countType = "imageCountMoreThan"
|
|
countNumber = 10
|
|
}
|
|
action = {
|
|
type = "expire"
|
|
}
|
|
}
|
|
]
|
|
})
|
|
} |