aws / dotnet

GitHub home for .NET development on AWS
https://aws.amazon.com/developer/language/net/
Apache License 2.0
544 stars 98 forks source link

DescribeInstanceStatusRequest returns nothing when instance is off even tough property IncludeAllInstances is set to true #39

Closed Xenunxenunowski closed 2 years ago

Xenunxenunowski commented 2 years ago

why does this code:

private static void GetInstanceState(AmazonEC2Client amazonEc2Client, string instanceId)
{
DescribeInstanceStatusRequest describeInstancesRequest = new DescribeInstanceStatusRequest();
describeInstancesRequest.InstanceIds.Add(instanceId);
describeInstancesRequest.IncludeAllInstances = true;
var response = amazonEc2Client.DescribeInstanceStatusAsync();
int responseTime = 0;
while (response.IsCompleted != true)
{
Thread.Sleep(1);
responseTime += 1;
}
Console.WriteLine("Successfully received instance state in "+ responseTime + " ms || " + responseTime/1000f + " s \n Response: "+response.Result.InstanceStatuses[0].InstanceState.Name);
}

returns error that InstanceStatuses is empty while my EC2 instance is off but when I turn it on it retrieves all data and displays it normally ? I specifically use DescribeInstanceStatusRequest.IncludeAllInstances = true; to get status of all instances as it is pointed out in the docs

https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstanceStatus.html

Xenunxenunowski commented 2 years ago

Opsie, looks like I posted an issue on the wrong repo :(

ashishdhingra commented 2 years ago

Duplicate of https://github.com/aws/aws-sdk-net/issues/2068