Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert elastic beanstalk classic load balancer to application load balancer on a running application?

I have several EB applications that I would like to convert from a classic to an application load balancer. In the documentation it seems that the default way is to create a new environment from scratch with the proper load balancer. Considering that I have many environment variables and several environments, I would prefer not to have to rebuild applications. Is there a way to switch out the load balancer on an already running application?

like image 775
sakurashinken Avatar asked May 17 '18 21:05

sakurashinken


People also ask

Is Elastic load balancer and classic load balancer same?

Classic Load Balancer overview A load balancer distributes incoming application traffic across multiple EC2 instances in multiple Availability Zones. This increases the fault tolerance of your applications. Elastic Load Balancing detects unhealthy instances and routes traffic only to healthy instances.

What is the difference between classic load balancer and application load balancer?

Application Load Balancer enables content-based routing and allows requests to be routed to different applications behind a single load balance. While the Classic Load Balancer doesn't do that, a single ELB can host single application. ALB isn't an improved Classic Load balancer. It's made on a completely new platform.


2 Answers

It is not possible to set a a load balancer type except at creation time. You can use elastic beanstalk cli and aws cli to clone the application with the same config and version. To get the deployed application version run:

aws elasticbeanstalk describe-environments --application-name ${APPLICATION_NAME} --environment-names ${SRC_ENV_NAME} | jq -r '.Environments | .[] |  .VersionLabel'

The jq pipe filters out the rest of the json blob.

After that, you can save the config of the curent appication using:

eb config save $SRC_ENV_NAME --cfg "${SRC_ENV_NAME}_save"

Then create an application clone using:

eb create $NEW_ENV_NAME --elb-type application --cfg "${SRC_ENV_NAME}_save" --version $APP_VERSION

Where APP_VERSION is the string extracted in step one.

like image 94
sakurashinken Avatar answered Jan 04 '23 12:01

sakurashinken


It is not simple, but it can be done.

If the Envivornment name is important to you, it gets a little trickier.

Here is it how it should go, step by step (using the web console):

  1. Save the configuration of the Environment you want to change
  2. From the Saved config, generate a new Env (select Customize settings) 2.1) Change the LB type to Application and fill out all the necessary info for this
  3. Swap the URLs from the original env to the new one (check if everything is working with the new env, if not swap back)

[STEPS ONLY NECESSARY IF ENV NAME IS IMPORTANT]

  1. Delete the original env (which now is not receiving traffic and has a Classic LB)
  2. Wait until the original name disappears from the console (it make take a couple of hours)
  3. Clone the production env, and give the new env the original env name
  4. Swap URLs
  5. Done!
like image 40
Christian Dechery Avatar answered Jan 04 '23 14:01

Christian Dechery