AWS SDK Version 3 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Describes the specified instances or all instances.

If you specify instance IDs, the output includes information for only the specified instances. If you specify filters, the output includes information for only those instances that meet the filter criteria. If you do not specify instance IDs or filters, the output includes information for all instances, which can affect performance. We recommend that you use pagination to ensure that the operation returns quickly and successfully.

If you specify an instance ID that is not valid, an error is returned. If you specify an instance that you do not own, it is not included in the output.

Recently terminated instances might appear in the returned results. This interval is usually less than one hour.

If you describe instances in the rare case where an Availability Zone is experiencing a service disruption and you specify instance IDs that are in the affected zone, or do not specify any instance IDs at all, the call fails. If you describe instances and specify only instance IDs that are in an unaffected zone, the call works normally.

Note:

For .NET Core and PCL this operation is only available in asynchronous form. Please refer to DescribeInstancesAsync.

Namespace: Amazon.EC2
Assembly: AWSSDK.EC2.dll
Version: 3.x.y.z

Syntax

C#
public virtual DescribeInstancesResponse DescribeInstances(
         DescribeInstancesRequest request
)
Parameters
request
Type: Amazon.EC2.Model.DescribeInstancesRequest

Container for the necessary parameters to execute the DescribeInstances service method.

Return Value
The response from the DescribeInstances service method, as returned by EC2.

Examples

This example describes the specified instance.

To describe an Amazon EC2 instance


var response = client.DescribeInstances(new DescribeInstancesRequest 
{
    InstanceIds = new List<string> {
        "i-1234567890abcdef0"
    }
});


            

This example describes the instances with the t2.micro instance type.

To describe the instances with a specific instance type


var response = client.DescribeInstances(new DescribeInstancesRequest 
{
    Filters = new List<Filter> {
        new Filter {
            Name = "instance-type",
            Values = new List<string> {
                "t2.micro"
            }
        }
    }
});


            

This example describes the instances with the Purpose=test tag.

To describe the instances with a specific tag


var response = client.DescribeInstances(new DescribeInstancesRequest 
{
    Filters = new List<Filter> {
        new Filter {
            Name = "tag:Purpose",
            Values = new List<string> {
                "test"
            }
        }
    }
});


            

Version Information

.NET Framework:
Supported in: 4.5, 4.0, 3.5

Portable Class Library:
Supported in: Windows Store Apps
Supported in: Xamarin Android
Supported in: Xamarin iOS (Unified)
Supported in: Xamarin.Forms

See Also