Skip to content

Instantly share code, notes, and snippets.

@xiaket
Last active June 26, 2023 12:24
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save xiaket/b16623765e11a657cbe52b61f1aeda8d to your computer and use it in GitHub Desktop.
Save xiaket/b16623765e11a657cbe52b61f1aeda8d to your computer and use it in GitHub Desktop.
ECR Lifecycle Policy example with explanations
{
"rules": [
{
"rulePriority": 10,
"description": "For `latest` tag, keep last 5 images",
"selection": {
"tagStatus": "tagged",
"tagPrefixList": ["latest"],
"countType": "imageCountMoreThan",
"countNumber": 5
},
"action": { "type": "expire" }
},
{
"rulePriority": 20,
"description": "For `master` tag, keep last 5 images",
"selection": {
"tagStatus": "tagged",
"tagPrefixList": ["master"],
"countType": "imageCountMoreThan",
"countNumber": 5
},
"action": { "type": "expire" }
},
{
"rulePriority": 990,
"description": "Only keep untagged images for 7 days",
"selection": {
"tagStatus": "untagged",
"countType": "sinceImagePushed",
"countUnit": "days",
"countNumber": 7
},
"action": { "type": "expire" }
},
{
"rulePriority": 1000,
"description": "Only keep tagged images for 15 days",
"selection": {
"tagStatus": "any",
"countType": "sinceImagePushed",
"countUnit": "days",
"countNumber": 15
},
"action": { "type": "expire" }
}
]
}
@avg00r
Copy link

avg00r commented Aug 27, 2020

all other images are those who have a tag, but not the protected ones, we should remove them if it's more than 15 days old.

What do you mean under protected ones? Which images are protected and by whom?

@xiaket
Copy link
Author

xiaket commented Aug 27, 2020

What do you mean under protected ones? Which images are protected and by whom?

The protected ones are those listed in 1 and 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment