I’m in the process of writing code to list out the Instance IDs and Instance Types using the .net SDK for AWS. I know I need to use the DescribeInstancesRequest class. I also think I need to use an ArrayList to store the string outputs and a foreach loop to grab all of the instances. I’m just having trouble putting it together! Something as simple as listing the Instance IDs in the console would be a great help to me.
Has anyone done something similar?
UPDATE 10/13/2012
I’m making very tiny steps towards getting to where I need to be. I’m brand new to the .net AWS SDK so this is a very slow process. The code below counts the number of instances I have and returns it. Now I just need to figure out how to have it list the actual instance IDs.
Any ideas?
AmazonEC2 ec2 = new AmazonEC2Client();
DescribeInstancesRequest request = new DescribeInstancesRequest();
DescribeInstancesResponse res = ec2.DescribeInstances(request);
Console.WriteLine(res.DescribeInstancesResult.Reservation.Count);
Console.Read();
Not to beat a dead horse, but for my task, I had to print out the Instance IDs and Instance Types in a HTML table. This could be useful if you want to host it on a website. All you need to do is change the path of
StreamWriter. Here is my sloppy however finished product.So keeping in mind I’m brand new to this, someone out there may be able to come up with a cleaner, more efficient, and better answer. This is how I got the instance ID and Instance Type to print in the console.