Solved

Can't get list of AWS instances

Posted on 2013-06-26
6
1,061 Views
Last Modified: 2014-11-12
I'm trying to get a list of all my AWS instances but so far no luck.

$client=[Amazon.AWSClientFactory]::CreateAmazonEC2Client($Access,$Secret)
$request = New-Object Amazon.EC2.Model.DescribeInstancesRequest
$response = $client.DescribeInstances($request)

but $response doesn't contain any data to work with. If I do  $response.DescribeInstancesResult, I get an empty result.
0
Comment
Question by:Mikex13
  • 3
  • 3
6 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 39280878
$client = [Amazon.AWSClientFactory]::CreateAmazonEC2Client($Access,$Secret)
$startReq = New-Object amazon.EC2.Model.StartInstancesRequest
$startReq.InstanceId.Add($instanceID);
$startResponse = $client.StartInstances($startReq)
$startResult = $startResponse.StartInstancesResult;
$startResult

Open in new window

0
 

Author Comment

by:Mikex13
ID: 39283175
#Sedgwick: Looking at your code, that starts an instance with a given instance ID. But what I'm after is the step before that: get a list of all instances.
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 39283737
Ok let me check
0
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 42

Assisted Solution

by:sedgwick
sedgwick earned 50 total points
ID: 39287873
$client=[Amazon.AWSClientFactory]::CreateAmazonEC2Client($Access,$Secret)

$request = New-Object -TypeName Amazon.EC2.Model.DescribeInstancesRequest
$response = $client.DescribeInstances($request)
foreach ($reservation in $response.DescribeInstancesResult.Reservation)
{ 
	foreach($instance in $reservation.RunningInstance)
	{

	}
}

Open in new window

0
 

Accepted Solution

by:
Mikex13 earned 0 total points
ID: 39288714
Got it to work - not only your code but also my initial code. The thing I was overlooking was the region. I thought the command would give me all the instances my "account" has access to but it only does it per region. If you don't set the region when defining the client, a default region is picked which might not be "your" region.

$client=[Amazon.AWSClientFactory]::CreateAmazonEC2Client($AccessKeyID,$SecretKeyID, $RegionEndpoint)
0
 

Author Closing Comment

by:Mikex13
ID: 39301490
Done some more research, looking at AWS SDKs and noticed the "region" parameter which I or previous posters have not mentioned before. Adding that parameter fixed my issue.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A brief introduction to what I consider to be the best editor for PowerShell.
A customer recently asked me about anti-malware and the different deployment options available for his business. Daily news about cyberattacks, zero-day vulnerabilities, and companies that suffered a security breach made him wonder if the endpoint a…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question