Skip to content

Instantly share code, notes, and snippets.

@hendrixroa
Created March 24, 2023 15:50
Show Gist options
  • Save hendrixroa/e3748396a294df8a2c89303669ed679a to your computer and use it in GitHub Desktop.
Save hendrixroa/e3748396a294df8a2c89303669ed679a to your computer and use it in GitHub Desktop.
AWS ECR untagged policies to remove images
resource "aws_ecr_lifecycle_policy" "default_policy" {
repository = aws_ecr_repository.noiselesstech.name
policy = <<EOF
{
"rules": [
{
"rulePriority": 1,
"description": "Keep only the last ${var.untagged_images} untagged images.",
"selection": {
"tagStatus": "untagged",
"countType": "imageCountMoreThan",
"countNumber": ${var.untagged_images}
},
"action": {
"type": "expire"
}
}
]
}
EOF
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment