35

Does anyone know if it's possible to change an existing AWS Elastic Beanstalk environment to an Application Load Balancer (instead of a classic one).

As far as I know only Application ELB's can be protected with AWS WAF and DDOS "Shield" so any existing EB app can't take advantage of these features since they have classic ELB's.

David
  • 7,652
  • 21
  • 60
  • 98

3 Answers3

29

It is not possible to change the load balancer type for an existing environment but I have used the following process to create a cloned environment with an application load balancer (instead of classic).

  1. In the console, save configuration of the original env.
  2. In terminal, eb config get [save name], you will get a file in .elasticbeanstalk\saved_configs .
  3. Edit the file to add

OptionSettings: aws:elasticbeanstalk:environment: LoadBalancerType: application

and remove (if you have those):

aws:elb:loadbalancer: CrossZone: true aws:elb:policies: ConnectionDrainingEnabled: true aws:elb:listener:443: [whatever]

You can use this opportunity to do other changes, such as upgrade PlatformArn

  1. Save modified config as [new save name].
  2. In terminal, eb config put [new save name] .
  3. Update your .ebextensions to have LoadBalancerType: application and optionally add listener to elbv2. You can also create in the console manually later.

aws:elbv2:listener:443: ListenerEnabled: true SSLPolicy: ELBSecurityPolicy-TLS-1-2-2017-01 SSLCertificateArns: [your cert id] DefaultProcess: default Protocol: HTTPS Rules: ''

  1. Create a new env with eb create [new env name] --cfg [new save name]

Now you will have a new environment with a different load balancer type side-by-side with your old environment. You can perform testing, make further configuration changes and then if all is well, swap CNAMEs and terminate the previous environment.

Arik Yavilevich
  • 421
  • 4
  • 6
  • This answer is nice, but it is not so easy to follow it to actually make the changes – Almog Cohen Aug 07 '19 at 23:35
  • This does not work anymore. editing , saving, uploading and loading the modified configuration now generates error "Unable to load configuration: Configuration validation exception: LoadBalancer type option cannot be changed." [![when I tried to do this ][1]][1] [1]: https://i.stack.imgur.com/7PgTJ.png – Kapil Aggarwal Sep 27 '19 at 12:58
  • 1
    @KapilAggarwal Are you creating a new environment with the new configuration or trying to apply the new configuration to the existing one? What happens if you use ``eb config put [new save name]`` as described and not the console for loading? – Arik Yavilevich Sep 28 '19 at 13:19
26

Hello As Per AWS Documentation:

The Elastic Beanstalk Environment Management Console only supports creating and managing an Elastic Beanstalk environment with a Classic Load Balancer. For other options, see Application Load Balancer and Network Load Balancer.

Also

Note You can only set the load balancer type during environment creation. (Refer AWS Documetnation)

So When you deploy application to Elastic Beanstalk via AWS CLI:

Try

eb create test-env --elb-type network

or

eb create test-env --elb-type application

Kush Vyas
  • 5,813
  • 2
  • 26
  • 36
  • 6
    Thanks, that's a shame. It means any existing environments can't be changed I'd presume then. – David Oct 10 '17 at 12:58
  • As of now no according to official AWS documentation , do mark question solved if the answer clears your doubts – Kush Vyas Oct 10 '17 at 13:02
  • Annoying how coy the official docs are about this in [other places](https://docs.aws.amazon.com/elasticloadbalancing/latest/userguide/migrate-to-application-load-balancer.html). You can use the EC2 load balancer migration wizard to generate a *second* application load balancer which forwards to the classic one, if you don't mind paying twice and it serves your purposes. – thadk Oct 23 '18 at 03:10
  • 2
    Seems like this answer is no longer true. It is possible to create the Application Load Balancer through the console. I did it myself too. https://aws.amazon.com/about-aws/whats-new/2018/04/aws-elastic-beanstalk-console-supports-alb--/ – Almog Cohen Aug 07 '19 at 23:24
  • indeed, one can now click the load balancer to configure it to any type, including shared application. It's still not possible to change it once configured though. – Vincent Gerris Jan 12 '21 at 23:32
  • ELB docs for EB moved to https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environments-cfg-alb.html – Patrick Jul 13 '22 at 15:32
5

The easiest way I've found to change an existing application to use the application load balancer is using both the Console and CLI:

  1. In the console, save the application configuration of the original env. Note this name down. We'll use it as <saved-config-name>.
  2. Under the Application versions note the latest Version Label. We'll use it as <app-version>.
  3. From the CLI run eb create <new-environment-name> --elb-type application --cfg <saved-config-name> --version <app-version>
  4. If you had HTTPs configured in the old application, in the newly created application reconfigure it in the Console under Load Balancer-->Listeners with the proper certificate.
Almog Cohen
  • 1,283
  • 1
  • 13
  • 12
  • 2
    It's worth noting that this in itself is not quite enough to update the complete EB environment - you will have to configure any load-balancer-related settings correctly, including eg listenes, SSL certs, security group configuration etc – danimal Oct 21 '19 at 15:23