Classic Load Balancer migration to ALB


AWS EC2 Classic have already been retired and the official deadline for migration is coming up.

Although its not mentioned directly,the official recommendation is to use to the new Application/Network Load Balancers over the Classic Load Bakancers in VPC.

We have a quick migration option available in the AWS management console but is not useful for Projects and Infra which are deployed/maintained using the Infrastructure as Code.

clb2

In this post we will go through the steps necessary to perform the migration with zero downtime using Cloudformation templates on a sample application.

Note:This sample application and cloud formation templates are internet facing and required further configuration and testing before using in live or prodcution environments.

Steps inovlved in the migration

  • Check and validate your existing Cloudformation template against exsiting Infrastructure.
  • Update the template with Application Load balancer changes.
  • Create new ALB while still serving traffic through the old Classic load balancer.
  • Slowly divert traffic to the new ALB.
  • Delete old classic load balancer using the Cloud formation.

I have executed above steps with a sample application and explained below

Prepare Sample application

The Cloudformation template here will create a Classic load balancer pointing to our sample application hosted on EC2.

The output of the same should be as below.

clb3

Deploy ALB with out deletion of the Classic Load balancer

This CF template will create a new Application load balancer which is going to replace our Classic load balancer created in step one.This is to ensure our new URL is ready and serving traffic before deleting the old endpoint.

The new URL should be serving our app.

clb4

Clean Old Classic Load Balancer

Once we are sure that the traffic is moved to the new URL i.e Application Load Balancer,we are good to run the last template which would delete our Classic Load Balancer.

clb5

Conclusion

Using this 3 step process we could easily migrate off from the Classic load balancer to Applcation load balancer with zero down time, which is very much need and appreciated on production environments.


Share on: