ECR repository life-cycle-policy

etc/scripts

·

1 min read

  • outline

When you create ECR repository, you need to create LifeCyclePolicy, too. Below is script that list ECR repository without LifeCyclePolicy on account.

  • script
#!/bin/bash
for i in $(aws ecr describe-repositories --query 'repositories[*].repositoryName[]' --output text)
        do
        ecr=$(aws ecr get-lifecycle-policy --repository-name $i 2>/dev/null)
        if [ $? == 0 ]; then
                echo good
        else echo $i has no life cycle policy
        fi
done