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

后端 未结 6 863
北海茫月
北海茫月 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: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
    

提交回复
热议问题