How to: use AWS Elastic Beanstalk to reduce risk of deployment downtime

by Ray
Published on December 2019

In this piece, we’ll be demonstrating how AWS Elastic Beanstalk can simplify deployments by doing all the hard work for you – and with no risk of downtime – by employing a Blue/Green deployment strategy.

Using AWS means combining a large number of tools to complete projects. Here at JAM, we choose to streamline this process by using Elastic Beanstalk, as it enables our dev teams to control the AWS resources which power the applications we support and gives us full access to the underlying resources at any time.

Elastic Beanstalk is a tool that will be familiar to anyone using AWS. However, if you’re new to the platform, Elastic Beanstalk is essentially an encapsulation of other AWS services. Whilst Beanstalk completes functions that can already be completed by using preexisting AWS tools, it also oversees and manages the whole process, so that you don’t have to spend time using each individual tool. All you have to do is tell it what end result you need, and Beanstalk will take care of the rest.

Beanstalk makes managing environments easy for developers. Instead of you having to painstakingly care for each one, Beanstalk will recognise when an instance is erroring, and will be able to kill the instance and spin up another one without you having to lift a finger.

Beanstalk can also make the process of deploying simple and easy. Here at JAM, we use Beanstalk for Blue/Green deployments. This is a deployment technique which reduces downtime and risk by running two identical production environments – Blue and Green, essentially, it’s a type of a/b testing. During the deployment, only one of these environments will be live and serving all traffic, whilst the other is being deployed to and tested on. Using Elastic Beanstalk, you can simplify this process down to its most basic steps, controlling everything at a high level whilst the finer details are taken care of.

So how do you do it? Follow the instructions below:

You’ll first need to spin up the environment you want to use within Elastic Beanstalk. If you’re already familiar with how Elastic Beanstalk works, you’ll be able to skip ahead to the instructions below; but if not, AWS has a developer guide which is a good starting point to get set up before you start with deployments, found here.

Step 1. Spin up the environment using Beanstalk.

Step 2. Go to the dashboard – this is where we can see all the details of the environment.

Step 3. You can see here that we need to upgrade – this is the perfect excuse to begin a blue/green deployment.

Environment Dashboard Elastic Beanstalk AWS

Step 4. Go to actions and click on “Clone Environment”.

Clicking this button has already saved us a huge amount of work by recreating all the functionalities and features of our original environment – e.g. load balancers, auto-scaling groups, ec2 instances and databases if you choose.

Clone environment

Step 5. This will take you to the clone dashboard.

This will take you to the clone dashboard. This is where you give it a new dashboard URL. We’re selecting to upgrade the platform, and click “Clone”. This will take a couple of minutes whilst Elastic Beanstalk takes care of everything for you.

Meanwhile, end-users will still be seeing the original site that has not been upgraded, and not experiencing any downtime.

Step 6. Now are both running – we can do all the testing we need to on the cloned environment.

Step 7. We will now swap the environments so that the upgraded one is the one for end-users.

Click on “Swap Environment URLs.” This swaps the URLs so that you don’t need to change the top-level DNS: AWS does everything for you internally. Traffic will now be re-routed to the clone.

Swap environment URLs

Step 8: Go back to the original environment and shut it down.

AWS Beanstalk enables you to easily create and destroy your servers and services, rather than keeping them unnecessarily. As you can see, the cloned environment has been shut down and the original is now back up and running after being upgraded.

Green and Blue Environments Elastic Beanstalk

Done! Easy right?

If you’ve got any questions about AWS tools, including Elastic Beanstalk, get in contact with our team here.



With partners across the USA, Europe and APAC, we provide a truly global service. So wherever you or your clients are based, contact us today to find out what we can do.