How to avoid a TooManyApplicationVersion exception on AWS Elastic Beanstalk?

Cause

The exception you are seeing stems from reaching your respective account limits for AWS Elastic Beanstalk, see section Errors in CreateApplicationVersion [paraphrased]:

  • TooManyApplicationVersions - The caller has exceeded the limit on the number of application versions associated with their account.
  • TooManyApplications - The caller has exceeded the limit on the number of applications associated with their account.

The current limits are outlined in the respective FAQ How many applications can I run with AWS Elastic Beanstalk?:

You can create up to 25 applications and 500 application versions. By default you can run up to 10 environments across all of your applications. If you are also using AWS outside of Elastic Beanstalk, you may not be [...] If you need more resources, complete the AWS Elastic Beanstalk request form and your request will be promptly evaluated. [emphasis mine]

Solution

As emphasized, AWS offers the usual escalation option and allows you to submit a Request to Increase AWS Elastic Beanstalk Limits, if you really need that many application versions to be available for reuse still. Otherwise you might just delete older ones you will not use anymore and the problem should vanish accordingly.

Good luck!


Here's a one liner that uses the AWS CLI that will help you clear out old application versions:

aws elasticbeanstalk describe-application-versions --output text --query 'ApplicationVersions[*].[ApplicationName,VersionLabel,DateCreated]' | grep "2014-02" | while read app ver date; do aws elasticbeanstalk delete-application-version --application-name $app --version-label $ver --delete-source-bundle; done

Replace the grep with whatever date, (2013, 2014-01, 2014-02-0, etc) you see fit.


As of EB CLI 3.3, you can now run the following to clear out old versions:

$ eb labs cleanup-versions

By default this will cleanup to the last 10 versions and/or older than 60 days. Adding --help, outputs the following:

usage: eb labs cleanup-versions [options...]

Cleans up old application versions.

optional arguments:
--num-to-leave NUM    number of versions to leave DEFAULT=10
--older-than DAYS     delete only versions older than x days DEFAULT=60
--force               don't prompt for confirmation