AWS Elastic Beanstalk
Developer Guide (API Version 2010-12-01)
AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Configuring Application Version Lifecycle Settings

Each time you upload a new version of your application with the Elastic Beanstalk console or the EB CLI, Elastic Beanstalk creates an application version. If you don't delete versions that you no longer use, you will eventually reach the application version limit and be unable to create new versions of that application.

You can avoid hitting the limit by applying an application version lifecycle policy to your applications. A lifecycle policy tells Elastic Beanstalk to delete application versions that are old, or to delete application versions when the total number of versions for an application exceeds a specified number.

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 before 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 six 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.

By default, Elastic Beanstalk leaves the application version's source bundle in Amazon S3 to prevent loss of data. You can delete the source bundle to save space.

You can set the lifecycle settings through the Elastic Beanstalk CLI and APIs. See eb appversion, CreateApplication (using the ResourceLifecycleConfig parameter), and UpdateApplicationResourceLifecycle for details.

Setting the Application Lifecycle Settings in the Console

You can specify the lifecycle settings in the console.

To specify your application lifecycle settings.

  1. Open the Elastic Beanstalk console.

  2. Choose an application.

  3. In the navigation pane, select Application versions.

  4. Select Settings.

    Application lifecycle settings
  5. Select Enable for Lifecycle policy to enable lifecycle settings.

  6. Select either Set the application versions limit by total count or Set the application versions limit by age.

  7. If you selected Set the application versions limit by total count, enter a value from 1 to 1000 for Application Versions to specify the maximum number of application versions to keep before deleting old versions.

  8. If you selected Set the application versions limit by age, specify the maximum age, in days from 1 to 180, of application versions to keep.

  9. For Retention, specify whether to delete the source bundle from S3 when the application version is deleted.

  10. For Service role, specify the role under which the application version is deleted.

  11. Select Save to save your application lifecycle settings.