Search code examples
amazon-web-servicesamazon-ec2amazon-elastic-beanstalkamazon-elb

Elastic Bean Stalk: Updating load balancer named: awseb-e-w-AWSEBLoa-xxxxx failed Reason: ELB cannot be attached to multiple subnets in the same AZ


I'm trying to get HTTPS connection for my ElasticBeanStalk environment, to accomplish this I'm following https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/configuring-https-elb.html, which implicates setting up a load balancer, when I configure the load balancer in the environment settings, the deploy fails with

"Updating load balancer named: awseb-e-w-AWSEBLoa-xxxxx failed Reason: ELB cannot be attached to multiple subnets in the same AZ. (Service: AmazonElasticLoadBalancing; Status Code: 409; Error Code: InvalidConfigurationRequest; Request ID: xxxx-xxxx-xxxx-xxxx-xxxx; Proxy: null)
"

I managed to get around this by unchecking some subnets in ElasticBeanStalk networks config. But when i do so the EC2 instance become unresponsive and can't even SSH to it and the environment get stuck on "No Data". It return responsive if i remove the load balancer.

How can i configure my subnets properly so that everything works? Thanks in advance!


Solution

  • Solved by doing this:

    After requesting a certificate in AWS Certificate Manager

    -Go to your environment configuration and choose "Load Balancer" (You may have to Change "Capacity" from "Single instance" to "Load Balanced" first )

    • Next choose "Add listener" and set it up like this

    PORT 443

    Protocol HTTPS

    Choose the SSL Certificate you requested in ACM

    SSL Policy is optional

    Done.

    Now open Route 53 and in "Hosted Zones" write your domain and point it to the Elastic Bean Stalk environment URI, this domain will now have HTTPS

    You may need to prepend https:// manually to the URL for the domain using the certificate, sometimes further configuration is needed for auto redirection.

    (Note that the elasticbeanstalk.com domain still won't have HTTPS)