How to Use AWS Elastic Beanstalk to Reduce Risk of Deployment Downtime

DZone 's Guide to

How to Use AWS Elastic Beanstalk to Reduce Risk of Deployment Downtime

You can use AWS Elastic Beanstalk to create and deploy an updated or upgrated application version with blue-green deployment using cloned configs.

· Cloud Zone ·
Free Resource

Learn to use AWS Beanstalk for blue-green deployments

In this piece, I’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. Personally, I choose to streamline this process by using Elastic Beanstalk, as it enables me and the rest of the dev team 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 recognize 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.

You may also enjoy: Deployment Orchestration With AWS Elastic Beanstalk

Beanstalk can also make the process of deploying simple and easy. One way of doing this is to use Beanstalk for Blue/Green deployments. This is a deployment technique that 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.

Upgrade needed

pgrade needed

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 — load balancers, auto-scaling groups, EC2 instances, and databases if you choose.

Clone environment

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.

Clone environment

Clone environment

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 URLs

Swap 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.

Cloned environment running

Cloned environment running

Done! Easy right?

Further Reading

Time Warping On AWS Elastic Beanstalk

Secure and Deploy Your Spring Boot App With AWS 

elastic beanstalk ,aws ,blue green deployment ,aws toolkit ,aws tools ,cloud ,cloned environment ,automation ,tutorial

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}