Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elastic Beanstalk reuse existing load balancer

Is it possible to reuse existing load balancer using elastic beanstalk?

like image 393
Arpan Solanki Avatar asked Oct 05 '16 13:10

Arpan Solanki


People also ask

Does Elastic Beanstalk use load balancer?

Elastic Beanstalk fully manages this load balancer, taking care of security settings and of terminating the load balancer when you terminate your environment.

How do I add a load balancer to an existing Elastic Beanstalk?

In the Load balancer configuration category, choose Edit. Select the Classic Load Balancer option, if it isn't already selected. Make any Classic Load Balancer configuration changes that your environment requires. Choose Save, and then make any other configuration changes that your environment requires.

When should you not use Elastic Beanstalk?

Elastic Beanstalk isn't great if you need a lot of environment variables. The simple reason is that Elastic Beanstalk has a hard limit of 4KB to store all key-value pairs. The environment had accumulated 74 environment variables — a few of them had exceedingly verbose names.

Is Elastic Beanstalk deprecated?

On July 18, 2022 Elastic Beanstalk set the status of all platform branches based on Amazon Linux AMI (AL1) to retired. For more information, see AL1 platform retirement FAQ in the AWS Elastic Beanstalk Developer Guide. The following sections provide information about all retiring platform versions.


2 Answers

As far as I could manage the only way I could get this to work was as follows:

  1. Create your environment as a single instance and not load balanced. You will find that EB creates an Auto Scaling group regardless.

  2. Manually create a Target Group for the EB environment (in the EC2 console under Target Groups)

  3. Assign the Target Group you just created to the Auto Scale group (in the EC2 console under Target Groups, click on the Auto Scale group and edit the details)

  4. Add the Listeners for the Target Group to the desired ALB

  5. Done

Managing scaling has to be done on the Auto Scale group directly as it remains disabled on the EB console.

Changing configurations and updating the application works and pushes to all instances.

I haven't tested upgrading the OS but I assume that it will work without issue as it won't likely rebuild the Auto Scaling group

Rebuilding the environment works but as the Auto Scale group gets rebuilt you need to reset the Target Group and auto-scaling configuration on it manually.

Update: I've been running several clients with this setup without issue for over a year.

like image 199
Marc G. Smith Avatar answered Oct 09 '22 10:10

Marc G. Smith


AWS now supports sharing of an Application Load Balancer among Elastic Beanstalk environments.

However, this can only be done during environment creation. Here're the steps to use a shared load balancer.

  1. Open the Elastic Beanstalk console, and in the Regions list, select your AWS Region.

  2. In the navigation pane, choose Environments.

  3. Choose Create a new environment to start creating your environment.

  4. On the wizard's main page, before choosing Create environment, choose Configure more options.

  5. Choose the High availability configuration preset.

    Alternatively, in the Capacity configuration category, configure a Load balanced environment type. For details, see Capacity.

  6. In the Load balancer configuration category, choose Edit.

  7. Select the Application Load Balancer option, if it isn't already selected, and then select the Shared option.

enter image description here

  1. Make any shared Application Load Balancer configuration changes that your environment requires.

  2. Choose Save, and then make any other configuration changes that your environment requires.

  3. Choose Create environment.

After doing the above steps, Elastic Beanstalk creates rules inside the shared load balancer.

The rules forward requests based on the Host header.

In the end, your shared load balancer will look like this:

enter image description here

If you want to modify the current EB environment to use shared ALB, I recommend the following steps:

  1. Use eb config get <saved_configuration_name> to download the current configuration of your environment.

  2. Modify the configuration on your local computer.

  3. Run eb config put <modified_configuration_name> to upload the configuration file to Elastic Beanstalk.

  4. Use the modified saved configuration to launch a new environment to replace the old environment.

like image 45
Brian Avatar answered Oct 09 '22 09:10

Brian