Menu
AWS Elastic Beanstalk
Developer Guide (API Version 2010-12-01)

Blue/Green Deployments with AWS Elastic Beanstalk

Because Elastic Beanstalk performs an in-place update when you update your application versions, your application may become unavailable to users for a short period of time. It is possible to avoid this downtime by performing a blue/green deployment, where you deploy the new version to a separate environment, and then swap CNAMEs of the two environments to redirect traffic to the new version instantly.

Blue/green deployments require that your environment runs independently of your production database, if your application uses one. If your environment has an Amazon RDS DB instance attached to it, the data will not transfer over to your second environment, and will be lost if you terminate the original environment.

For details on configuring your application to connect to an external (not managed by Elastic Beanstalk) Amazon RDS instance, see Using Elastic Beanstalk with Amazon RDS.

To perform a blue/green deployment

  1. Open the Elastic Beanstalk console.

  2. Navigate to the management console for your environment.

  3. In the navigation pane, click Application Versions.

  4. Click Upload.

    1. Enter a label for this version in the Version Label field.

    2. Enter a brief description for this version in the Description field.

    3. Enter a label for this version in the Version label field.

    4. (Optional) Enter a brief description for this version in the Description field.

    5. Click Browse to specify the location of the source bundle.

    The file you specified is associated with your application; you'll deploy the new application version to a new environment.

  5. Save the configuration for the live environment by opening the environment's dashboard, clicking Actions and then selecting Save Configuration.

    For more information, see Saved Configurations. You'll use this configuration to create a new environment that will run the updated application version.

  6. Launch a new environment with your new application version and saved configuration. For more information, see Creating an AWS Elastic Beanstalk Environment.

  7. Verify that your new environment is ready by viewing its dashboard. If the environment has an error, view the events and logs for the environment in order to troubleshoot any errors.

  8. From the new environment's dashboard, click Actions and then select Swap Environment URLs.

  9. From the Environment name drop-down list, select the current live environment name in order to use that environment's URL for the new environment.

    Swap Environment URL Window
  10. Click Swap.

  11. After Elastic Beanstalk completes the swap operation, verify that the new environment responds when you try to connect to the old environment URL. However, do not terminate your old environment until the DNS changes have been propagated and your old DNS records expire. DNS servers do not necessarily clear old records from their cache based on the time to live (TTL) you set on your DNS records. Therefore, we recommend that you wait an additional period of time after the TTL before you terminate your environment.