Browsed by
Category: Elastic Load Balancer

Subnet and VPC Gotcha’s When Using An Elastic Load Balancer

Subnet and VPC Gotcha’s When Using An Elastic Load Balancer

So I’ve successfully migratedĀ this site to a load balanced environment using an Elastic Load Balancer. There are a coupleĀ “gotcha’s” that I ran into while doing this, and I want to jot them down before I forget:

  1. I wanted to create multiple subnets for a load balanced environment across availability zones, but since my original subnet was the same size as my VPC (e.g. 10.0.0.0/16 = 10.0.0.0/16), I had no IP ranges left to create new subnets. So to have multiple subnets, one must create subnets smaller than the VPC IP range. I ended up having to create an entirely new VPC with smaller subnets.
  2. I wanted to have each of my two web servers in different availability zones. To do this one simply launches an instance into different subnets, since one subnet equals one availability zone. After I got my new VPC and subnets created, I launched two EC2 instances using an AMI of the original WordPress EC2 host. I needed to SSH into each of them to change the database host endpoint (I also had to recreate my DB host in the new VPC). I was able to SSH into one host, but not the other. After some troubleshooting, I realized that one of the subnets did not have an Internet Gateway in the route table. Turns out that when creating a new VPC, AWS automatically assigns an Internet Gateway to the first subnet you create, but not for any additional subnets you create afterwards. For those you must add the Internet Gateway manually to the Route Table.