0
  • Load balancers cost an hourly rate
  • (Re)creating EB costs uploads to S3 and takes a long time

So for EB that is sitting idle (used only during development), just as EC2 can be scaled down to 0 instances, how can the load balancer be toggled off (and later toggled back on)? Could Terraform be employed, such that the absence of the ALB is detected and gets recreated with an apply?

I already terminate EC2 instances under EB when idle, but all the while my unused load balancer is charging me! Ideally I'd have a zero cost during idle time, by also deleting the load balancer. But when I go to recreate the ALB when needed, Terraform state isn't explicitly tracking the ALB (it's managed by EB environment), so it doesn't get recreated.

I know Elastic Beanstalk environments can be created without load balancers. I'm hoping the "scalability" of AWS provides a cleaner and faster approach to just toggling the existence of the load balancer besides recreating the whole EB environment.

ecoe
  • 4,994
  • 7
  • 54
  • 72
  • That is not possible simple because AWS doesn't provide that feature. – Stargazer Jun 10 '19 at 18:27
  • If you need zero cost during idle time, should you go with serverless with new design? Think about it, more than struggle with current situation. – BMW Jun 11 '19 at 02:24
  • 1
    @BMW in 10 years or less I bet your suggestion will be the general solution, but as of 2019 serverless designs (e.g. using Lambda, API Gateway, or AppSync) still can have latency issues, typically exceeding 1 second (in addition to the "cold start" issue). – ecoe Jul 25 '19 at 11:32
  • Good point!. Serverless can't cover many cases which is sensitive about the latency. If this is the main reason you choice Elastic beanstalk, then seems it has no other choice to avoid using ALB/ELB – BMW Jul 26 '19 at 00:13

1 Answers1

1

You can temporarily disable all Elastic Beanstalk infrastructure that costs money, allowing you to suspend the application for free until you're ready to turn it back on, without the expense of destroying and recreating it from scratch.

Via the EB Environment Configuration:

  1. (temporarily) demote Capacity
    • from: Environment type: load balancing, auto scaling
    • to: Single-Instance Environment
  2. Delete the single instance and static ip it generates
  3. Just to be safe, ensure your autoscaling group config allows a maximum of 0 instances

Leave running for months this way, without paying a dime...

Then, You can turn everything back on the way it was quickly:

  1. Switch Load balancing back on and ensure autoscaling group has non-zero instance count.
  2. terraform refresh to import the new instance ids of your autoscaling targets
  3. resume using terraform as usual (e.g. plan, apply)
ecoe
  • 4,994
  • 7
  • 54
  • 72