| Did this page help you? Yes No Tell us about it... |
This topic uses an example to walk you through the process for creating a basic HTTP load balancer on Amazon VPC and registering your EC2 instances with the newly created VPC load balancer. This example uses default configurations for security group, listener protocols and ports, and for the health check.
The following task list gives you a general overview of the steps you'll need to follow to create a basic load balancer in Amazon VPC. After this task list you'll step through detailed procedures for each part of the creation process.
Creating a Basic Load Balancer in Amazon VPC
|
1 |
Configure the listeners for your load balancer by specifying the ports and protocols to use for front-end connection (client to load balancer) and back-end connection (load balancer to back-end instance). |
|
2 |
Configure a health check for your Amazon EC2 back-end instances. |
|
3 |
Select the subnets to launch your load balancer. |
|
4 |
Select security groups to assign to your load balancer. |
|
5 |
Add instances to your load balancer. |
|
6 |
Review settings. |
|
7 |
Create and test your load balancer. |
You can choose to create your load balancer within Amazon VPC using the AWS Management Console, the command line interfaces, or Query API.
To create a basic load balancer in your Amazon VPC
Start the Create Load Balancer wizard:
In the Amazon EC2 Console Dashboard page, click Load Balancers in the Navigation pane.

On the Load Balancers page, click Create Load Balancer.
On the DEFINE LOAD BALANCER page, enter a name for your Amazon VPC load balancer (e.g., MyVPCLoadBalancer).
Click the arrow in the Create LB inside box and select the virtual private cloud in which you want to create your load balancer.
Leave the Listener Configuration set to the default value.

Click Continue to configure the health check for your instances.
Configure the health check settings that your application requires.

Click Continue to select the subnet in which you want to launch your load balancer instance.
In the Available Subnets table, click the green button at the left to select the subnet in which you want to have your load balanced instances.

Your selected subnets are displayed in the Selected Subnets table.

Click Continue to select security groups to assign to your load balancer.
If you use a pre-existing security group, ensure that it allows ingress to the ports that you configured the load balancer to use. If you create a security group in this step, the console will define these ports to be open for you. This example uses the default security group associated with your virtual private cloud.
Select Choose one or more of your existing Security Groups and then select the default security group.

Click Continue to add running EC2 instances to your load balancer.
In the Manually Add Instances to LoadBalancer table, check the boxes in the Select column to add instances to your load balancer.

![]() | Note |
|---|---|
When you register a multi-homed instance (an instance that has an Elastic Network Interface attached) with your load balancer, the load balancer will route traffic to the primary IP address of the instance (eth0). For more information on using Elastic Network Interfaces, go to Elastic Network Interfaces. |
Click Continue to review your configuration. On the REVIEW page, click Create to create your load balancer.
This example walks you through the process for creating a basic HTTP load balancer on Amazon VPC and registers Amazon EC2 instances with the newly created VPC load balancer. This example uses a default security group.
To create a basic load balancer in your Amazon VPC
Call CreateLoadBalancer using the following
parameters:
Subnets =
subnet-450f512c
Listener
Protocol = HTTP
InstanceProtocol = HTTP
InstancePort = 8080
LoadBalancerPort = 80
LoadBalancerName = MyVPCLoadBalancer
SecurityGroups =
sg-b9ffedd5
The operation returns the DNS name of your load balancer. You can then map any other domain name (such as www.example.com) to your load balancer’s DNS name using CNAME or some other technique.
To register your Amazon EC2 instances with your VPC load balancer
You should only register instances that are in the Pending or Running state and are in a Virtual Private Cloud (VPC).
Call RegisterInstancesWithLoadBalancer with the following parameters:
LoadBalancerName = MyVPCLoadBalancer
Instances = [ i-4f8cf126, i-0bb7ca62 ]
![]() | Note |
|---|---|
When you register a multi-homed instance (an instance that has an Elastic Network Interface attached) with your load balancer, the load balancer will route traffic to the primary IP address of the instance (eth0). For more information on using Elastic Network Interfaces, go to Elastic Network Interfaces. |
For detailed descriptions of the Elastic Load Balancing API actions, see Elastic Load Balancing API Reference.
This example walks you through the process for creating a basic HTTP load balancer on Amazon VPC and registers Amazon EC2 instances with the newly created VPC load balancer. This example uses a default security group that is open to the internet on port 80.
To create a basic load balancer in your Amazon VPC
Enter the command elb-create-lb as in the following example.
PROMPT> elb-create-lb MyVPCLoadBalancer --subnets subnet-4e05f721 --groups sg-b9ffedd5 --listener "lb-port=80,instance-port=8080,protocol=http,instance-protocol=http"
Elastic Load Balancing returns the following:
DNS-NAME DNS-NAME DNS-NAME MyVPCLoadBalancer-2111276808.us-east-1a.elb.amazonaws.com
To register your Amazon EC2 instances with your VPC load balancer
You should only register instances that are in the Pending or Running state and are in a Virtual Private Cloud (VPC).
Use the elb-register-instances-with-lb command as in the following example.
PROMPT> elb-register-instances-with-lb MyVPCLoadBalancer --instances i-4f8cf126,i-0bb7ca62
Elastic Load Balancing returns the following:
INSTANCE INSTANCE-ID INSTANCE i-4f8cf126 INSTANCE i-0bb7ca62
![]() | Note |
|---|---|
When you register a multi-homed instance (an instance that has an Elastic Network Interface attached) with your load balancer, the load balancer will route traffic to the primary IP address of the instance (eth0). For more information on using Elastic Network Interfaces, go to Elastic Network Interfaces. |
For detailed descriptions of the Elastic Load Balancing commands, see the Elastic Load Balancing Quick Reference Card.