Oneiros
Oneiros

Reputation: 273

How to change elastic beanstalk environment type from load-balanced to single instance

I have an elastic beanstalk environment that uses a load-balancer. It is also has a http to https configuration. I want to change the environment type from load-balanced to single instance (because I realized I'm not using the app as much and the costs are running high). I tried to do so by going to configuration settings, capacity settings and switch from the load-balancer option to the single instance option. Firstly, I get a warning "Migrating to a single-instance environment replaces all of your current instances and reduces your capacity." with this code. aws:elasticbeanstalk:environment:EnvironmentType "LoadBalanced" => "SingleInstance"

And then it fails with this error Service:AmazonCloudFormation, Message:Template format error: Unresolved resource dependencies [AWSEBV2LoadBalancer] in the Resources block of the template

The only file in my ebextensions folder is a http to https configuration file with this code

Resources:
 AWSEBV2LoadBalancerListener:
  Type: AWS::ElasticLoadBalancingV2::Listener
  Properties:
    LoadBalancerArn:
      Ref: AWSEBV2LoadBalancer
    Port: 80
    Protocol: HTTP
    DefaultActions:
      - Type: redirect
        RedirectConfig:
          Host: "#{host}"
          Path: "/#{path}"
          Port: "443"
          Protocol: "HTTPS"
          Query: "#{query}"
          StatusCode: "HTTP_301"

And then a "FAILED TO DEPLOY CONFIGURATION"

Upvotes: 2

Views: 1658

Answers (1)

Marcin
Marcin

Reputation: 238249

If you switch to single-instance, you will not have ALB. This means you can't use AWS::ElasticLoadBalancingV2::Listener in your ebextnations and you have to re-factor entire HTTPS handling.

Basically, you have to modify your EB to handle HTTPS by its own. If you used SSL cert from ACM, you have to get new one from a third party (not AWS), as ACM certs can't be used on your single-instance EB environment.

Upvotes: 3

Related Questions