One of my application is configured for auto deployment with Code Deploy and Elastic Beanstalk on AWS hosting. Today the deployment failed with the error message “Too many application versions, cannot create a new version for application my-app“. See the below screenshot of error message:
After searching about the issue, I found that Elastic Beanstalk keeps all application version’s deployed in past. So when we deploy a new version it keeps old version and there is a limit of 500 versions (by default) per region per AWS account. To delete the old version follow below steps:
Delete Beanstalk Application Versions
- Login to AWS account and Open the Elastic Beanstalk console
- Choose Applications in navigation pane, and then select your application name from the 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.
Delete application versions dialog on the Application Versions page of the Elastic Beanstalk console
Then click Delete button to delete all versions.
(Optional) You can clear the check box for Delete versions from Amazon S3 to leave the application source bundle for these application versions in your Amazon Simple Storage Service (Amazon S3) bucket.
You can also configure to delete Elastic Beanstalk old versions automatically. To do this you need to enable application version lifecycle settings. Which will also applied to the new application versions.