Amazon EC2 Container Service
Developer Guide (API Version 2014-11-13)

Creating a Classic Load Balancer

This section walks you through the process of creating a Classic Load Balancer in the AWS Management Console.

Note that you can create your Classic Load Balancer for use with EC2-Classic or a VPC. Some of the tasks described in these procedures apply only to load balancers in a VPC.

Define Your Load Balancer

First, provide some basic configuration information for your load balancer, such as a name, a network, and a listener.

A listener is a process that checks for connection requests. It is configured with a protocol and a port for front-end (client to load balancer) connections and a protocol, and protocol and a port for back-end (load balancer to back-end instance) connections. In this example, you configure a listener that accepts HTTP requests on port 80 and sends them to the back-end instances on port 80 using HTTP.

To define your load balancer

  1. Open the Amazon EC2 console at

  2. From the navigation bar, select a region for your load balancer. Be sure to select the same region that you selected for your Amazon ECS container instances.

  3. In the navigation pane, under LOAD BALANCING, choose Load Balancers.

  4. Choose Create Load Balancer.

  5. On the Select load balancer type page, choose Classic Load Balancer.

  6. For Load Balancer name, enter a unique name for your load balancer.

    The load balancer name you choose must be unique within your set of load balancers, must have a maximum of 32 characters, and must only contain alphanumeric characters or hyphens.

  7. For Create LB inside, select the same network that your container instances are located in: EC2-Classic or a specific VPC.

  8. The default values configure an HTTP load balancer that forwards traffic from port 80 at the load balancer to port 80 of your container instances, but you can modify these values for your application. For more information, see Listeners for Your Classic Load Balancer in the User Guide for Classic Load Balancers.

  9. [EC2-VPC] To improve the availability of your load balancer, select at least two subnets in different Availability Zones. Your load balancer subnet configuration must include all Availability Zones that your container instances reside in. In the Select Subnets section, under Available Subnets, select the subnets. The subnets that you select are moved under Selected Subnets.


    If you selected EC2-Classic as your network, or you have a default VPC but did not choose Enable advanced VPC configuration, you do not see Select Subnets.

                                Selected subnets
  10. Choose Next: Assign Security Groups to go to the next page in the wizard.

Assign a Security Group to Your Load Balancer in a VPC

If you created your load balancer in a VPC, you must assign it a security group that allows inbound traffic to the ports that you specified for your load balancer and the health checks for your load balancer. Amazon ECS does not automatically update the security groups associated with Elastic Load Balancing load balancers or Amazon ECS container instances.


If you selected EC2-Classic as your network, you do not see this page in the wizard and you can go to the next step. Elastic Load Balancing provides a security group that is assigned to your load balancer for EC2-Classic automatically.

To assign a security group to your load balancer

  1. On the Assign Security Groups page, choose Create a new security group.

  2. Enter a name and description for your security group, or leave the default name and description. This new security group contains a rule that allows traffic to the port that you configured your load balancer to use. If you specified a different port for the health checks, you must choose Add Rule to add a rule that allows inbound traffic to that port as well.


    You should also assign this security group to container instances in your service, or another security group with the same rules.

                                Select security groups
  3. Choose Next: Configure Security Settings to go to the next page in the wizard.

(Optional) Configure Security Settings

For this tutorial, you can choose Next: Configure Health Check to continue to the next step. For more information about creating a HTTPS load balancer and using additional security features, see HTTPS Load Balancers in the User Guide for Classic Load Balancers.

Configure Health Checks for Your EC2 Instances

Elastic Load Balancing automatically checks the health of the tasks in your service. If Elastic Load Balancing finds an unhealthy task, it stops sending traffic to the instance and reroutes traffic to healthy instances. Amazon ECS stops your unhealthy task and starts another instance of that task.


The following procedure configures an HTTP (port 80) load balancer, but you can modify these values for your application.

To configure a health check for your instances

  1. On the Configure Health Check page, do the following:

    1. Leave Ping Protocol set to its default value of HTTP.

    2. Leave Ping Port set to its default value of 80.

    3. For Ping Path, replace the default value with a single forward slash ("/"). This tells Elastic Load Balancing to send health check queries to the default home page for your web server, such as index.html or default.html.

    4. Leave the other fields at their default values.

                                Configure health check
  2. Choose Next: Add EC2 Instances to go to the next page in the wizard.

Load Balancer Instance Registration

Your load balancer distributes traffic between the instances that are registered to it. When you assign your load balancer to an Amazon ECS service, Amazon ECS automatically registers and deregisters container instances when tasks from your service are running on them. Because Amazon ECS handles container instance registration, you do not add container instances to your load balancer at this time.

To skip instance registration and tag the load balancer

  1. On the Add EC2 Instances page, for Add Instances to Load Balancer, ensure that no instances are selected for registration.

  2. Leave the other fields at their default values.

  3. Choose Next: Add Tags to go to the next page in the wizard.

Tag Your Load Balancer (Optional)

You can tag your load balancer, or continue to the next step. Note that you can tag your load balancer later on; for more information, see Tag Your Classic Load Balancer in the User Guide for Classic Load Balancers.

To add tags to your load balancer

  1. On the Add Tags page, specify a key and a value for the tag.

  2. To add another tag, choose Create Tag and specify a key and a value for the tag.

  3. After you are finished adding tags, choose Review and Create.

Create and Verify Your Load Balancer

Before you create the load balancer, review the settings that you selected. After creating the load balancer, you can create a service that uses it to verify that it's sending traffic to your container instances.

To finish creating your load balancer

  1. On the Review page, check your settings. If you need to make changes to the initial settings, choose the corresponding edit link.

  2. Choose Create to create your load balancer.

  3. After you are notified that your load balancer was created, choose Close.

Create an Amazon ECS Service

After your load balancer is created, you can specify it in a service definition when you create a service. For more information, see Creating a Service.