!/bin/bash
rev_arry=$(aws ecs list-task-definitions --family-prefix
--query taskDefinitionArns[]|cut -f7 -d :| cut -c1-2)
maxrev_num=($rev_arry)
arrlen=$((${#maxrev_num[@]}-2))
latest_revision=$(aws ecs list-task-definitions --family
--sort desc --max-items 1 --query taskDefinitionArns|cut -c64-65)
n="1"
while [ $n -lt $arrlen ]
do
if [ ${maxrev_num[n]} -eq $latest_revision ];
then
n=$[$n+1]
fi
delrevision=${maxrev_num[n]}
aws ecs deregister-task-definition --task-definition :$delrevision
echo "ecr taskdefiniton:$delrevision is deleted"
n=$[$n+1]
done
No comments:
Post a Comment