63

I would like to switch off Elastic Load Balancer (ELB) for my Elastic Beanstalk environment.

Currently I don't need it and I don't want to pay for it.

It is possible to delete the ELB in EC2 managment window but then Elastic Beanstalk health state is switched from GREEN to RED. I just found a information that it's not possible.

Does someone has a trick how to run Elastic Beanstalk without load balancing and have environment GREEN health state?

Calaf
  • 8,037
  • 8
  • 46
  • 96
amra
  • 13,390
  • 7
  • 45
  • 46
  • 3
    I'm afraid you cannot remove the load balancer from Elastic Beanstalk since its part of the package. You can do something else which may require a bit more configuration - you can create a CloudFormation script that uses a predefined AMI (probably something similar to what Beanstalk uses) and do all the deployment on your own. – Eran Sandler Feb 06 '12 at 14:48
  • I believe you can grab the Elastic IP associated with your load balancer from the EC2 management page, and associate it directly with your app server instance. I expect the preconfigured health monitoring would still fall over, though - so more changes would be needed to get everything "green" again. – rvalue Mar 21 '12 at 23:01
  • Do you not want to pay for the _entire_ EB application or just the load balancer? There [is a way to sustain your EB without any instances or a load balancer](https://stackoverflow.com/a/58596954/1080804) (so it's temporarily suspended for free), and you can still turn it back on fairly quickly later on. – ecoe Apr 02 '20 at 19:16

4 Answers4

60

Since July 2013 Elastic Beanstalk supports "single-instance" environments that have a single container instance running without a load balancer. Existing environments that are set up using "load balancing environment" can be switched to "single instance" and vice versa.

Prior to this it was not possible to remove the load balancer and have Elastic Beanstalk still work correctly. The load balancer is an integral part of the way that Elastic Beanstalk works in "load-balancing environment" configurations.

Ken Liu
  • 21,056
  • 17
  • 71
  • 96
  • 6
    This fails for me with "Auto Scaling EvaluationPeriods setting cannot be applied because AWSEBCloudwatchAlarmHigh doesn't exist" and "Load Balancer HealthCheck setting cannot be applied because AWSEBLoadBalancer doesn't exist" and then "Failed to update settings: Configuration validation exception: Auto Scaling EvaluationPeriods setting cannot be applied because AWSEBCloudwatchAlarmHigh doesn't exist." – orome Feb 14 '15 at 21:46
  • single instance also eliminates the autoscaling, I'm only want to eliminate the ELB to build a custom worker. my app needs to have two environments, one web based and one worker, and it seems we can only pick one ? – Mathieu J. Jul 10 '20 at 08:25
35

In the new Elastic Beanstalk interface I noticed the option to create my environment as a single instance.

Dropdown with options "Single instance" and "Load balancing, autoscaling".

I tried it out and, as one might expect, it didn't create an Elastic Load Balancer. Hooray!

The options are described in the AWS EB documentation. At first I recreated the environments I don't need to balance automatically, but apparently you can even switch environment type on the fly.

lime
  • 6,193
  • 3
  • 36
  • 48
  • This doesn't work (see my comment on the [answer above](http://stackoverflow.com/a/12736032/656912)). – orome Feb 14 '15 at 21:47
  • @raxacoricofallapatorius, it sounds like you have an issue with your Elastic Beanstalk configuration, which does not really relate to this particular question. Maybe you should ask it as a new question, e.g. on [Server Fault](http://serverfault.com/)? – lime Feb 16 '15 at 13:52
  • 2
    I think I found the issue (basically a documentation omission): I've set some ELB related things in my `.ebextensions` config files. Those all need to be deleted or commented out in the config files and deployed, before the change of environment type can be attempted. – orome Feb 16 '15 at 15:02
  • This worked for me. Note: If you happen to get the error "Health based rolling updates can not be enabled for single instance environments", you'll need to change your rolling update type to Time Based, as specified here: https://forums.aws.amazon.com/thread.jspa?messageID=640868 – StCleezy Oct 02 '16 at 02:46
  • I feel like you _should_ be able to do this with multiple instances AND no ELB (e.g. as part of a target group and another ALB) – Andy Hayden Dec 23 '17 at 00:37
  • upvoted! if you turn off the load balancer, can you still use the SSL??? – PirateApp Jun 26 '19 at 10:12
  • Yes you can still use SSL without a load balancer but it's not as easy to configure. – Risteard Jul 22 '19 at 15:51
9

From command line you can do it like this

eb create -s

Note When activating the single instance mode (-s switch) neither the load balancer nor the auto scaling group is created

An alternative approach is to create a worker environment either through the console

enter image description here

or through CLI

eb create -t Worker
Peter Szanto
  • 6,723
  • 2
  • 43
  • 50
  • 1
    Creating a worker is not a good idea since it needs to be attached to a SQS queue and also pings localhost:80/ for health status – Marcelo Mar 06 '19 at 19:09
6

In a saved configuration, or module-specific env.yaml, use this :

OptionSettings: aws:elasticbeanstalk:environment: EnvironmentType: SingleInstance

To create a single-instance EB environment.

gileri
  • 402
  • 5
  • 11