describeInstances method
This API works with the following fleet types:EC2, Container
Retrieves information about the EC2 instances in an Amazon GameLift Servers managed fleet, including instance ID, connection data, and status. You can use this operation with a multi-location fleet to get location-specific instance information. As an alternative, use the operations https://docs.aws.amazon.com/gamelift/latest/apireference/API_ListCompute and https://docs.aws.amazon.com/gamelift/latest/apireference/API_DescribeCompute to retrieve information for compute resources, including EC2 and Anywhere fleets.
You can call this operation in the following ways:
- To get information on all instances in a fleet's home Region, specify the fleet ID.
- To get information on all instances in a fleet's remote location, specify the fleet ID and location name.
- To get information on a specific instance in a fleet, specify the fleet ID and instance ID.
If successful, this operation returns Instance objects for
each requested instance, listed in no particular order. If you call this
operation for an Anywhere fleet, you receive an InvalidRequestException.
Learn more
Remotely connect to fleet instances
Related actions
May throw InternalServiceException.
May throw InvalidRequestException.
May throw NotFoundException.
May throw UnauthorizedException.
May throw UnsupportedRegionException.
Parameter fleetId :
A unique identifier for the fleet to retrieve instance information for.
You can use either the fleet ID or ARN value.
Parameter instanceId :
A unique identifier for an instance to retrieve. Specify an instance ID or
leave blank to retrieve all instances in the fleet.
Parameter limit :
The maximum number of results to return. Use this parameter with
NextToken to get results as a set of sequential pages.
Parameter location :
The name of a location to retrieve instance information for, in the form
of an Amazon Web Services Region code such as us-west-2.
Parameter nextToken :
A token that indicates the start of the next sequential page of results.
Use the token that is returned with a previous call to this operation. To
start at the beginning of the result set, do not specify a value.
Implementation
Future<DescribeInstancesOutput> describeInstances({
required String fleetId,
String? instanceId,
int? limit,
String? location,
String? nextToken,
}) async {
_s.validateNumRange(
'limit',
limit,
1,
1152921504606846976,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'GameLift.DescribeInstances'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'FleetId': fleetId,
if (instanceId != null) 'InstanceId': instanceId,
if (limit != null) 'Limit': limit,
if (location != null) 'Location': location,
if (nextToken != null) 'NextToken': nextToken,
},
);
return DescribeInstancesOutput.fromJson(jsonResponse.body);
}