cannot deploy - ERROR: You cannot have more than 500 Application Versions

后端 未结 6 861
北海茫月
北海茫月 2021-02-06 20:57

I get the following error when deploying to EB:

ERROR: You cannot have more than 500 Application Versions. Either remove some Application Versions or re

相关标签:
6条回答
  • 2021-02-06 21:26

    At the time of writing this answer, eb labs cleanup-versions does not work for me: it returned No application versions to delete even when I had application versions.

    As a workaround, I used this one-liner inspired from this answer (change the region and app name accordingly):

    aws elasticbeanstalk describe-application-versions --output text --region=us-west-2 --query 'ApplicationVersions[*].[ApplicationName,VersionLabel,DateCreated]' | grep my-app-name | while read app ver date; do echo "deleting version $app $ver $date" ; aws elasticbeanstalk delete-application-version --region=us-west-2 --application-name $app --version-label $ver --delete-source-bundle; done

    0 讨论(0)
  • 2021-02-06 21:33

    You can manage lifecycle policies from the AWS console now.

    1. In the Actions drop-down on the right hand side of the application you'd like to manage, click View application versions.

    2. Click on the Settings button on the top right and you'll be able to configure the amount of versions you'd like to keep around:

    3. If you have already reached the limit, you must manually first delete some versions to allow this lifecycle policy to kick in (for an explanation read the note below).

    Note

    From the Configuring Application Version Lifecycle Settings documentation:

    Elastic Beanstalk applies an application's lifecycle policy each time you create a new application version, and deletes up to 100 versions each time the lifecycle policy is applied. Elastic Beanstalk deletes old versions after creating the new version, and does not count the new version towards the maximum number of versions defined in the policy.

    Elastic Beanstalk does not delete application versions that are currently being used by an environment, or application versions deployed to environments that were terminated less than ten weeks before the policy was triggered.

    The application version limit applies across all applications in a region. If you have several applications, configure each application with a lifecycle policy appropriate to avoid reaching the limit. Elastic Beanstalk only applies the policy if the application version creation succeeds, so if you have already reached the limit, you must delete some versions manually prior to creating a new version.

    0 讨论(0)
  • 2021-02-06 21:34

    I find the solution here, the simple solution is to delete the previous versions as explained below.

    To delete an application version

    • Open the Elastic Beanstalk console, and in the Regions list, select your AWS Region.

    • In the navigation pane, choose Applications, and then choose your application's name from the list.

    Note

    If you have many applications, use the search bar to filter the application list.

    In the navigation pane, find your application's name and choose Application versions.

    • Select one or more application versions that you want to delete.

    • Choose Actions, then choose Delete.

    • (Optional) To leave the application source bundle for these application versions in your Amazon Simple Storage Service (Amazon S3) bucket, clear the box for Delete versions from Amazon S3.

    • Choose Delete.

    Another solution

    Go to version settings and enable lifecycle policy the way it is shown below.

    Reference: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/applications-versions.html

    0 讨论(0)
  • 2021-02-06 21:39

    There's no built in way to do that, but the following ruby script performs just that. Simply schedule it using cron.

    clearnup.rb:
    
    application_name="myApp"
    active_versions_shell_output = `aws elasticbeanstalk describe-environments --region=us-east-1 | grep git | awk '{gsub(/.*\:\ \"/,"",$0); print}'`
    all_versions_shell_output = `aws elasticbeanstalk describe-applications --region=us-east-1 | grep git | awk '{gsub(/.*\ \"/,"",$0); print}'`
    all_versions = all_versions_shell_output.split(/\n/).map{|x| x[0..57]}
    active_versions = active_versions_shell_output.split(/\n/).map{|x| x[0..57]}
    
    (all_versions - active_versions).each do |version_to_be_deleted|
        puts "deleting #{version_to_be_deleted}"
      `aws elasticbeanstalk delete-application-version --delete-source-bundle --application-name #{application_name} --version-label #{version_to_be_deleted}`
    end
    
    0 讨论(0)
  • 2021-02-06 21:43

    A feature was recently added to eb cli (v3.3) to cleanup old versions

    https://m.reddit.com/r/aws/comments/340ce0/whats_the_thinking_behind_beanstalks_versioning/

    Copying command from reddit link

    $ eb labs cleanup-versions --help
    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
    
    0 讨论(0)
  • 2021-02-06 21:53

    Now, they have added an admin UI page to delete all application versions:

    Managing Application Versions

    0 讨论(0)
提交回复
热议问题