Created
April 30, 2025 11:39
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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