Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lucas-candido-mytech/8755b98d620a604bf7f016b070184ee6 to your computer and use it in GitHub Desktop.
Save lucas-candido-mytech/8755b98d620a604bf7f016b070184ee6 to your computer and use it in GitHub Desktop.
Definir Life Cycle para ECR manter 10 imagens em cada repo
for repo in $(aws ecr describe-repositories --query 'repositories[*].repositoryName' --output text); do
aws ecr put-lifecycle-policy \
--repository-name "$repo" \
--lifecycle-policy-text '{
"rules": [
{
"rulePriority": 1,
"description": "Keep only the 10 most recent images",
"selection": {
"tagStatus": "any",
"countType": "imageCountMoreThan",
"countNumber": 10
},
"action": {
"type": "expire"
}
}
]
}'
echo "Policy applied to $repo"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment