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

Solution 1:

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

Solution 2:

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: Lifecycle policies

  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.