문제

Lately has anyone witnessed the

TooManyApplicationVersions Exception

on AWS Elastic Beanstalk console while deploying a new application version (war)? It's so annoying to see this message as it appears only after you have finished uploading the war.

I would be interested to know why this exception occurs and what precautions one should take to avoid such situations?

도움이 되었습니까?

해결책

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

You're approaching maximum number of versions and need to delete old or unused ones.

In the current web console you can simply do it on the Application Versions tab of your Beanstalk environment.

enter image description here

This is the piece of code that we use in our deploy script to delete the oldest application version.

console.log('Deleting oldest application version.');
params = {};
local.waitFor(function(done) {
    eb.describeApplicationVersions(params, function(err, data) {
        if (err) {
            console.error(err, err.stack);
            local.abort('Could not retrieve the list of application version.');
        } else {
            // This is probably not needed as the list is already sorted but it is
            // not written anywhere that this will always be the case
            function compare(a,b) {
                if (a.DateCreated > b.DateCreated)
                    return -1;
                if (a.DateCreated < b.DateCreated)
                    return 1;
                return 0;
            }
            var applicationsVersion = data['ApplicationVersions'].sort(compare),
                oldestApplication   = applicationsVersion[applicationsVersion.length - 1],
                applicationName     = oldestApplication['ApplicationName'],
                versionLabel        = oldestApplication['VersionLabel'];
            params = {
                ApplicationName: applicationName, /* required */
                VersionLabel:    versionLabel,    /* required */
                DeleteSourceBundle: false /* Do not delete source bundle from S3 */
            };
            eb.deleteApplicationVersion(params, function(err, data) {
                if (err) {
                    console.error(err, err.stack);
                    local.abort('Could not delete the oldest application version. (' + versionLabel + ')')
                } else {
                    console.log('Successfully deleted the oldest application version. (' + versionLabel + ')');
                }
            });
        }
    });
});

Documentation for the Elastic Beantalk API (js): http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/ElasticBeanstalk.html

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top