Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Method of finding instances attached to ELB

I am using the Amazon AWS ELB command line tools. Is there a way of finding out the instances attached to a particular Elastic Load Balancer (ELB)?

like image 604
sheki Avatar asked Sep 16 '10 11:09

sheki


People also ask

How do I find my EC2 instance load balancer?

Log in to the Amazon Web Services Management Console and click EC2. Click Load Balancers. The Load Balancers section of the console is divided into upper and lower panes. When you choose a load balancer from the upper pane, details about the load balancer appear in the lower pane.

What is ELB instance?

Elastic Load Balancing automatically distributes your incoming traffic across multiple targets, such as EC2 instances, containers, and IP addresses, in one or more Availability Zones. It monitors the health of its registered targets, and routes traffic only to the healthy targets.

How do I find my instance history?

Click the instance that you're interested in. Under Resources, click Console history. Click View current history.

Is ELB an EC2 instance?

High availabilityThe most well-known service that relies on ELB is Amazon's EC2, as ELB performs a health check to ensure an instance is still running before sending traffic to it. When an instance fails or is unhealthy, ELB routes traffic to the remaining healthy EC2 instances.


1 Answers

2013/12/18: To update this and since the links are dead!

I installed the new AWS cli tools:

$ pip install awscli

Then ran:

$ aws configure                                                                                                                                                
AWS Access Key ID [None]: my-key
AWS Secret Access Key [None]: my-secret
Default region name [None]: us-east-1
Default output format [None]:

This data is saved into ~/.aws/config.

Then I can find instances connected to a loadbalancer like so:

$ aws elb describe-load-balancers --load-balancer-name "my-name"
{
    "LoadBalancerDescriptions": [
        {
            "Subnets": [],
            "CanonicalHostedZoneNameID": "ID",
            "CanonicalHostedZoneName": "my-name-foo.us-east-1.elb.amazonaws.com",
            "ListenerDescriptions": [
                {
                    "Listener": {
                        "InstancePort": 80,
                        "LoadBalancerPort": 80,
                        "Protocol": "HTTP",
                        "InstanceProtocol": "HTTP"
                    },
                    "PolicyNames": []
                },
                {
                    "Listener": {
                        "InstancePort": 80,
                        "SSLCertificateId": "arn:aws:iam::x:server-certificate/x-ssl-prod",
                        "LoadBalancerPort": 443,
                        "Protocol": "HTTPS",
                        "InstanceProtocol": "HTTP"
                    },
                    "PolicyNames": [
                        "AWSConsole-SSLNegotiationPolicy-api-production"
                    ]
                }
            ],
            "HealthCheck": {
                "HealthyThreshold": 10,
                "Interval": 30,
                "Target": "HTTP:80/healthy.php",
                "Timeout": 5,
                "UnhealthyThreshold": 2
            },
            "BackendServerDescriptions": [],
            "Instances": [
                {
                    "InstanceId": "i-FIRST-INSTANCEID"
                },
                {
                    "InstanceId": "i-SECOND-INSTANCEID"
                }
            ],
            "DNSName": "my-name-foo.us-east-1.elb.amazonaws.com",
            "SecurityGroups": [],
            "Policies": {
                "LBCookieStickinessPolicies": [],
                "AppCookieStickinessPolicies": [],
                "OtherPolicies": [
                    "AWSConsole-SSLNegotiationPolicy-my-name"
                ]
            },
            "LoadBalancerName": "my-name",
            "CreatedTime": "2013-08-05T16:55:22.630Z",
            "AvailabilityZones": [
                "us-east-1d"
            ],
            "Scheme": "internet-facing",
            "SourceSecurityGroup": {
                "OwnerAlias": "amazon-elb",
                "GroupName": "amazon-elb-sg"
            }
        }
    ]
}

The data is in LoadBalancerDescriptions.Instances.

My loadbalancer is called my-name — this is the name you selected when you created it.

Old answer below!

I'm not familiar with the cli tool, but I used the API.

I'd check these two requests:

  • DescribeLoadBalancers
  • DescribeInstanceHealth

The cli tool probably has something to resemble these?

HTH!

like image 50
Till Avatar answered Sep 21 '22 13:09

Till