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
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