How to Seamlessly Update an Application on AWS Elastic Beanstalk


Before you begin, you need to:


  1. Open a web browser and log into your AWS Elastic Beanstalk dashboard.

Consider the following scenario: You have a single instance application with two environments, known as Primary and Secondary. This is a typical configuration if you do testing as part of your release cycle.

Each of these application environments has a single EC2 instance behind it. Note that both Primary and Secondary are running the same versions of the application.

You can check the status of the application by clicking on the link below “All Applications” as shown in the example below:

You will then see the application instance dashboard. Here you will find information about the health status, the running version, and even the URL currently in use, as shown in the callout below:

Using the URL, you can view the live application. This is very useful if you are actively testing changes. All is well here; the application is in good health and running, as we would expect it to be.

Now, let’s say you have made some changes to the application — for instance, to the title of your page. You have some new code to upload to the secondary environment so you can begin testing. You navigate to the secondary environment’s dashboard and click on “Upload and Deploy”:

This will display a dialogue box asking which Zip file you wish to upload. Select Choose File to begin:

The version label, by default, will autofill based on the name of the Zip file you are uploading. Once you have selected the application file you want to upload, select Deploy. You’ll return to the application dashboard, and the process of deploying your new application version has begun:

Notice that the “Health” status is now gray. This is expected. You may be at this screen for a few seconds or up to a few minutes depending on the size of your application. Once completed, you should see the new version of your application under Running Version and the Health status should be green once more:

You can verify the changes are working by visiting the URL currently assigned to this instance. It may take a moment or two to refresh, but that is expected.

As you will see back on the All Applications dashboard, the primary and secondary application instances now have different running versions:

All changes made to the application have been tested and verified. The next task now is to make the secondary application instance the primary so you can get the application into production for your customer. To do so, we are going to swap URLs, making the secondary application instance take over the primary instance URL.

The single instance application URL is still displaying the old running version:

To swap the URLs, first select the Actions drop-down menu and choose Swap Environment Urls. Yes, it’s that easy!

A dialogue window will appear:

The first step is to select the environment we want to swap to. In the above example, it’s the secondary application instance. In the second step, we want to select the environment we want to swap with. Essentially, we are telling AWS Elastic Beanstalk that we want to use the primary application instance’s URL to display the new application version, and give the secondary application instance’s URL to the primary.

When you are satisfied with the changes, the third and final step is to select Swap. This will begin the process of switching the DNS records in the background. Be patient here, as it could take some time to complete. Once the swap has occurred, the primary application instance URL should be displaying the running version of the secondary application instance, and the secondary application instance URL should be displaying the previous running version.

In the example above, the title has changed from the previous version.

That is how you can update an application on AWS Elastic Beanstalk. For more examples of how easy it is to update applications using the AWS Elastic Beanstalk platform, be sure to refer to the AWS Elastic Beanstalk documentation and watch the companion snip located here:

Do you think you can beat this Sweet post?

If so, you may have what it takes to become a Sweetcode contributor... Learn More.

Josh King is the Senior Infrastructure & Automation Administrator at a local government body in regional New Zealand, working within a predominantly Windows and VMware environment. Josh has a passion for PowerShell and automation. You can find his blog at or reach out to him on Twitter, @WindosNZ.


Click on a tab to select how you'd like to leave your comment

Leave a Comment

Your email address will not be published. Required fields are marked *