Is there a way to list all Elastic Load Balancers? (Using AWS .NET SDK)

1.1k views Asked by At

I am trying to get the status of my Load Balancers programmatically and that proves quite problematically as I have to enter an incredibly long string for the ARN (Or I guess with the Name, which is shorter, I get the same result, but that's beside the point). If I keep setting up new ELBs and deleting the old ones (just assume I would do such a weird thing) I'm having a hard time keeping track of all of my ELBs that are currently set up.

Ideally, I would want to use a command that outputs a list of all of my ELB's Names or ARNs and with that, I can call the API as in the sample below.

AmazonElasticLoadBalancingV2Client balancingClient = newAmazonElasticLoadBalancingV2Client(region: regEndpoint);
var response = balancingClient.DescribeLoadBalancers(new DescribeLoadBalancersRequest
                    {
                        LoadBalancerArns =
                        {
                            //Incredibly long string
                            //Might be amazing to replace this 
                            //with a fancy little Method that just 
                            //returns a string or an array of strings
                        }
                    });
var loads = response.LoadBalancers;

Do you by any chance know a way to get that?

2

There are 2 answers

7
Mark B On BEST ANSWER

If you just call DescribeLoadBalancers() without passing it a list of load balancers to describe, it will return a list of all your load balancers.

0
Stiv Ostenberg On

I ran into problems like this, and built a solution I call the AWS Trycorder. I have been adding more and more data to the AWS Trycorder, which basically is just an information gatherer of AWS account data across all our accounts. It is hosted on Github, and one of the libraries contains code for sucking up data from various AWS services. You are welcome to mine it for functions, or use it directly. It gets tricky, as sometimes the data cannot be collected from a single request, but a specific request has to be made for each resource. For example, if you want to find out where the log is for a beanstalk instance, you have to request data specifically for that instance. The library tries to make all those calls so the data you need is in a single table. There is a website at http:\trycorder.stiv.com that gives an overview, but the site does not list a lot of the new features.