Search code examples
amazon-elastic-beanstalkaws-application-load-balancer

Automatically re-register instance to target group on SHARED Load Balancer


enter image description here

Above you can se an ilustration of my aws environment. Maybe this will help ilustrate the problem.

I have a DEV environment with multiple Beanstalk projects being managed by one Shared Application Load Balancer.

It works great pointing the listeners to each target groups BUT

IF I Rebuild an environment or by any chance AWS kills one of my instances I have to manually re-register that new instance to the respective target group.

Is that any way to do it automatically? I've tried autoscalling groups with no success.


Solution

  • I'm guessing you already found a solution but just in case you didn't. I had this same issue and the answer was indeed the Auto-Scaling groups.

    After you configure and create the EB envinronment with the shared load balancer. An Auto-Scaling group will be automatically created for this envinronment, this is where you add your custom target group, you add it to your Auto-Scaling group on the Load Balancing tab under Load balancer target groups

    I haven't found a way to create a custom Auto-scaling group and assign it before hand so Elastic Beanstalk doesn't create one automatically. But adding your custom target group to the Auto-Scaling group that is created by EB has worked without issues for all my projects.

    TL;DR:

    1. Create your EB environment (Shared load Balancer configuration)
    2. Create your custom target group
    3. Add it to the Auto-Scaling group that was automatically generated when you created your EB Environment.
    4. Remove the automatically generated target group that will be on the Auto-Scaling group, it's not needed anymore.