1234567891011121314151617181920212223242526272829303132333435363738394041 |
- # Simple lifecycle policy that expires images that are untagged, or over 1 year old.
- #
- # Lifecycle policies for ECR aren't very powerful. To do better than this,
- # we would need to change the way we tag images. But ECR is nearly as cheap
- # as S3 storage, so a few extra images isn't going to hurt anybody.
- resource "aws_ecr_lifecycle_policy" "basicpolicy" {
- repository = aws_ecr_repository.this.name
- policy = <<EOF
- {
- "rules": [
- {
- "rulePriority": 1,
- "description": "Remove Untagged Images",
- "selection": {
- "tagStatus": "untagged",
- "countType": "sinceImagePushed",
- "countUnit": "days",
- "countNumber": 1
- },
- "action": {
- "type": "expire"
- }
- },
- {
- "rulePriority": 2,
- "description": "Remove images older than 1 year",
- "selection": {
- "tagStatus": "any",
- "countType": "sinceImagePushed",
- "countUnit": "days",
- "countNumber": 365
- },
- "action": {
- "type": "expire"
- }
- }
- ]
- }
- EOF
- }
|