LoginSignup
2
2

More than 5 years have passed since last update.

ElasticBeanstalkでTooManyApplicationVersionsExceptionが出た時の対応

Last updated at Posted at 2017-11-30

CircleCIからElasticBeanstalkへ自動デプロイしていると、
そのうちTooManyApplicationVersionsExceptionというエラーが出てしまうという
問題に対応したので、その備忘録

awsの管理コンソールでもライフサイクルを決めることができるのに
なぜそれで対応できないのか…というのはおいておいて

shell scriptで

REGION=【region】
APP_NAME=【application name】
ENABLE_APPLICATION_COUNT=+200

aws elasticbeanstalk describe-application-versions --output text --region=$REGION --query 'ApplicationVersions[*].[ApplicationName,VersionLabel,DateCreated]' \
| grep $APP_NAME \
| tail -n $ENABLE_APPLICATION_COUNT \
| while read app ver date;
do
    echo "deleting version $app $ver $date";
    aws elasticbeanstalk delete-application-version --region=$REGION --application-name $app --version-label $ver --delete-source-bundle;
    sleep 1
done

こんな感じでregion application name を設定すれば
最新200アプリケーションを残して、あとは自動削除をしてくれる

2
2
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2