Browsed by
Category: EC2

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.
Oops! Creating AMI’s Shuts Down Services

Oops! Creating AMI’s Shuts Down Services

So this afternoon I was playing around with creating AMI’s. After I created an AMI based on the EC2 instance hosting this website, the website went down. When I logged into the instance I found that Apache wasn’t running. After some quick searching, I found out that during the AMI creation process, services are stopped unless otherwise specified. And I had made the rookie mistake of not setting the run level for the httpd service so that Apache would start up automatically after reboot. Lesson learned.

New AWS Feature: EC2 Screenshot

New AWS Feature: EC2 Screenshot

I just learned today that AWS has a new feature for Amazon EC2. It’s called Instance Console Screenshot. From the AWS website:

Instance Console Screenshot provides an on-demand screenshot of the instance console, conveying valuable debug information. This capability is particularly useful when diagnosing instances that have become unreachable via RDP (Windows) or SSH (Linux) due to in-progress software updates, VM Import issues, or other blocking system events. Screenshots can be viewed in the AWS console or accessed via the AWS API or CLI, with both Linux and Windows instances supported.

Certainly not as useful as a live interactive console, but very helpful in debugging non-responsive or unreachable instances.