I get the following error when deploying to EB:
ERROR: You cannot have more than 500 Application Versions. Either remove some Application Versions or request a limit increase.
I went manually and deleted some versions. I don't want deploys to fail because of this limit. Is there a way in Elastic Beanstalk to auto-evict unused versions?
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
There's no built in way to do that, but the following ruby script performs just that. Simply schedule it using cron.
You can manage lifecycle policies from the AWS console now.
Note
From the Configuring Application Version Lifecycle Settings documentation:
At the time of writing this answer,
eb labs cleanup-versions
does not work for me: it returnedNo 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):
Now, they have added an admin UI page to delete all application versions:
Managing Application Versions