Skip to content

Commit

Permalink
Merge pull request #1553 from cloud-gov/ecr-lifecycle
Browse files Browse the repository at this point in the history
add terraform to remove images without tags
  • Loading branch information
dandersonsw authored Sep 16, 2024
2 parents 838ea9b + 452e165 commit 1d9b4b8
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions terraform/stacks/ecr/stack.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,29 @@ resource "aws_ecr_repository" "repository" {
tags = {}
tags_all = {}
}

resource "aws_ecr_lifecycle_policy" "ecr_repository_lifecycle_policy" {
for_each = var.repositories

repository = each.key

policy = <<EOF
{
"rules": [
{
"rulePriority": 1,
"description": "Expire images without tags",
"selection": {
"tagStatus": "untagged",
"countType": "sinceImagePushed",
"countUnit": "days",
"countNumber": 1
},
"action": {
"type": "expire"
}
}
]
}
EOF
}

0 comments on commit 1d9b4b8

Please sign in to comment.