Going CLI with ELB


Getting started with ELB
Basic ELB concepts
ELB: practical usage
Start course

Load Balancing refers to distributing workloads across multiple computing resources in order to avoid overloading some nodes while leaving others underused. When properly configured, load balancing can greatly increase an infrastructure's availability and performance, optimize throughput and response time, and generally improve the system effectiveness.

AWS has a purpose-build load balancing service called Elastic Load Balancing (ELB). Since the effective use of load balancers is so important even to many smaller deployments, instructor David Clinton crafted this introductory course, covering all the main concepts and practical application of ELB.

Who should take this course

As this is a beginner to intermediate course, you should be able to grasp all the core concepts with just about any background level. Nevertheless you may want to take our introductory EC2 and VPC courses first. Also, our Introduction to AWS might be another good, quick tutorial if you haven't yet seen that.

As a follow up to this course, check out our ELB questions set, and our advanced course How to Architect with a Design for Failure Approach, where you'll get the chance to see ELB in action providing high availability and fault tolerance in a cloud architecture.

If you have thoughts or suggestions for this course, please contact Cloud Academy at support@cloudacademy.com.


In this video, we'll learn how to manage Load Balancers from the command line using the AWS command line tool. First, we'll have to quickly install the command line tool. You may already have the command line tool installed, or you may have seen this in a different video. But let's, at any rate, review these steps.

First, make sure that Python is installed and is a recent version, 2.7.6 is fine. Now, sudo apt-get install a few tools, Unzip we'll need, and wget we'll need. Let's now use wget to download the AWS CLI tool. Let's use the Unzip utility to unzip the package, the AWSCLIbundle.zip package. And now, we will run the executable package itself under sudo. It seems to be installed. To configure, we simply type AWS configure. It asks us for our Amazon account access key ID, and then it asks us for our secret access key.

Don't worry, if you want to copy that down and take all the time, it won't do you a lot of good because this access key will have been deleted long before you actually see this video. Now, it asks us which region we'd like to access from this command line, so we'll go with us-east-1.

And finally, which output format would you like to use; we'll go with table. The other two options, of course, are JSON and text. We're done. Now that we've got the command line tool installed.

Let's start using it. We always preface an AWS CLI command with AWS to tell Ubuntu or Linux that we're now accessing the AWS system. Then we type ELB, which stands for Elastic Load Balancer to tell AWS that we're accessing that part of their system. And then we issue a command, which in this case is describe-load-balancers.

That will describe all the load balancers that are currently associated with the account we've authenticated to. And if we scroll up a little bit, we see that there is, currently, one load balancer. Its name is internal balancer. It's part of this VPC, and its scheme is internal as opposed to an internet-facing load balancer. Let's scroll down a little bit more. These are the health check parameters that we've set on this load balancer. It has these two EC2 instances associated with it.

These are its listeners. In other words, this is how it listens and reroutes traffic coming from the internet.

This is its security group, and these are the three subnets on which it can manage instances. Now, let's run aws ec2 describe-instances, to see all the instances that are available in this region associated with this account.

There's a quick way to get the information we're really after. When the output describes instances, it gives us our instance ID. Let's copy instance ID.

You copy from the keyboard with a shift+ctrl c. Let's run the same command we did before, but this time, grep instance id.

This will print out the contents of every line in the output which have the word "instance ID" in it. That's better. There are three instances, and these are their IDs. Similarly, we can "describe security-groups", with a dash before the "g". This will output all our security groups, from which we could also learn the IDs of the various security groups available. We'll use this information soon. Now let's create a new load balancer. We start off again with AWS, and then ELB to show that we are using the Electric Load Balancer part of the AWS system. The command is "create load balancer". The Load Balancer name will be "myVPCbalancer". The listeners, that is the way that the load balancer will accept traffic from the internet, will be on protocol HTTP, and the load balancer port will be 80. And it will reroute all that data to HTTP again in all the way back here through port 80 on the instances. The subnet we're going to use is D72DFBA0, which happens to be the subnet on which our instances are running.

How do I know that? Well, we could go back to the browser and look it up in the dashboard interface of AWS, or we could also search through the described instances output that we did before, this time for subnet.

In this this case, just take my word for it, this is a subnet that we're after. The security group we've chosen is again, taken from the output of the described security groups. And its ID happens to be SG for security group, 37BCB452. Let's create this load balancer. It's done. Now, let's add a couple of instances to the load balancer, because a load balancer without instances to balance, is not much of a load balancer. So again, AWS ELB, register instances with load balancer to tell Amazon that we want to add instances to be balanced. The load balancer name is "MyVPCBalancer", that's what we just created, and this identifies that this is a load balancer from all the load balancers on our system that we're working on right now. And the instances we're adding are these two; ib85 and id59, etc.

Let's hit enter, and it worked. We now have a load balancer that has instances associated with it to manage. Finally, we always have to learn how to clean up any mess that we've made before we really get started with the mess. Let's delete this load balancer we've just created. It was just for demonstration purposes, in any case. You use the command "aws elb", then delete load balancer and "--load balancer name" will be "MyVPCBalancer". Let's one more time, just to be sure. Let us list the load balancers that we have in total, to make sure that the "MyVPCBalancer" is not among them, "aws elb describe load balancers", I think that's what it was.

Balancers. And it seems to have been. Scroll up, and there's only one. The original one that we had before we started. There are maybe 10 or 12 other commands that are specific to the ELB CLI. You can see those easily on the AWS Amazon documentation pages. But at the very least, you now have a pretty good idea of how the command line Interface works in relation to load balancing.

About the Author
David Clinton
Linux SysAdmin
Learning Paths

David taught high school for twenty years, worked as a Linux system administrator for five years, and has been writing since he could hold a crayon between his fingers. His childhood bedroom wall has since been repainted.

Having worked directly with all kinds of technology, David derives great pleasure from completing projects that draw on as many tools from his toolkit as possible.

Besides being a Linux system administrator with a strong focus on virtualization and security tools, David writes technical documentation and user guides, and creates technology training videos.

His favorite technology tool is the one that should be just about ready for release tomorrow. Or Thursday.