Skip to content

describe_instances

describe_instances(
    *,
    config_overrides: Optional[GameLiftClientConfig] = None,
    fleet_id: Optional[FleetIdOrArn] = None,
    instance_id: Optional[InstanceId] = None,
    limit: Optional[PositiveInteger] = None,
    next_token: Optional[NonZeroAndMaxString] = None,
    location: Optional[LocationStringModel] = None,
) -> DescribeInstancesOutput

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.

Use the pagination parameters to retrieve results as a set of sequential pages.

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

Debug fleet issues

Related actions

All APIs by task

Parameters:

  • fleet_id (Optional[FleetIdOrArn], default: None ) –

    A unique identifier for the fleet to retrieve instance information for. You can use either the fleet ID or ARN value.

  • instance_id (Optional[InstanceId], default: None ) –

    A unique identifier for an instance to retrieve. Specify an instance ID or leave blank to retrieve all instances in the fleet.

  • limit (Optional[PositiveInteger], default: None ) –

    The maximum number of results to return. Use this parameter with NextToken to get results as a set of sequential pages.

  • next_token (Optional[NonZeroAndMaxString], default: None ) –

    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.

  • location (Optional[LocationStringModel], default: None ) –

    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.

Raises:

  • InternalServiceException –

    The service encountered an unrecoverable internal failure while processing the request. Clients can retry such requests immediately or after a waiting period.

  • InvalidRequestException –

    One or more parameter values in the request are invalid. Correct the invalid parameter values before retrying.

  • NotFoundException –

    The requested resource was not found. The resource was either not created yet or deleted.

  • UnauthorizedException –

    The client failed authentication. Clients should not retry such requests.

  • UnsupportedRegionException –

    The requested operation is not supported in the Region specified.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_gamelift/_services/game_lift.py
def describe_instances(
    self,
    *,
    config_overrides: Optional[GameLiftClientConfig] = None,
    fleet_id: Optional["capo_gamelift.types.fleet_id_or_arn.FleetIdOrArn"] = None,
    instance_id: Optional["capo_gamelift.types.instance_id.InstanceId"] = None,
    limit: Optional["capo_gamelift.types.positive_integer.PositiveInteger"] = None,
    next_token: Optional[
        "capo_gamelift.types.non_zero_and_max_string.NonZeroAndMaxString"
    ] = None,
    location: Optional[
        "capo_gamelift.types.location_string_model.LocationStringModel"
    ] = None,
) -> "capo_gamelift.types.describe_instances_output.DescribeInstancesOutput":
    """<p> <b>This API works with the following fleet types:</b> EC2, Container</p> <p>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 <a href="https://docs.aws.amazon.com/gamelift/latest/apireference/API_ListCompute">https://docs.aws.amazon.com/gamelift/latest/apireference/API_ListCompute</a> and <a href="https://docs.aws.amazon.com/gamelift/latest/apireference/API_DescribeCompute">https://docs.aws.amazon.com/gamelift/latest/apireference/API_DescribeCompute</a> to retrieve information for compute resources, including EC2 and Anywhere fleets.</p> <p>You can call this operation in the following ways:</p> <ul> <li> <p>To get information on all instances in a fleet's home Region, specify the fleet ID.</p> </li> <li> <p>To get information on all instances in a fleet's remote location, specify the fleet ID and location name.</p> </li> <li> <p>To get information on a specific instance in a fleet, specify the fleet ID and instance ID.</p> </li> </ul> <p>Use the pagination parameters to retrieve results as a set of sequential pages. </p> <p>If successful, this operation returns <code>Instance</code> objects for each requested instance, listed in no particular order. If you call this operation for an Anywhere fleet, you receive an InvalidRequestException.</p> <p> <b>Learn more</b> </p> <p> <a href="https://docs.aws.amazon.com/gamelift/latest/developerguide/fleets-remote-access.html">Remotely connect to fleet instances</a> </p> <p> <a href="https://docs.aws.amazon.com/gamelift/latest/developerguide/fleets-creating-debug.html">Debug fleet issues</a> </p> <p> <b>Related actions</b> </p> <p> <a href="https://docs.aws.amazon.com/gamelift/latest/developerguide/reference-awssdk.html#reference-awssdk-resources-fleets">All APIs by task</a> </p>

    Args:
        fleet_id: <p>A unique identifier for the fleet to retrieve instance information for. You can use either the fleet ID or ARN value.</p>
        instance_id: <p>A unique identifier for an instance to retrieve. Specify an instance ID or leave blank to retrieve all instances in the fleet.</p>
        limit: <p>The maximum number of results to return. Use this parameter with <code>NextToken</code> to get results as a set of sequential pages.</p>
        next_token: <p>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.</p>
        location: <p>The name of a location to retrieve instance information for, in the form of an Amazon Web Services Region code such as <code>us-west-2</code>. </p>

    Raises:
        capo_gamelift.errors.internal_service_exception.InternalServiceException: <p>The service encountered an unrecoverable internal failure while processing the request. Clients can retry such requests immediately or after a waiting period.</p>
        capo_gamelift.errors.invalid_request_exception.InvalidRequestException: <p>One or more parameter values in the request are invalid. Correct the invalid parameter values before retrying.</p>
        capo_gamelift.errors.not_found_exception.NotFoundException: <p>The requested resource was not found. The resource was either not created yet or deleted.</p>
        capo_gamelift.errors.unauthorized_exception.UnauthorizedException: <p>The client failed authentication. Clients should not retry such requests.</p>
        capo_gamelift.errors.unsupported_region_exception.UnsupportedRegionException: <p>The requested operation is not supported in the Region specified.</p>
        capo_gamelift.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_gamelift.types.describe_instances_input.DescribeInstancesInput]",
    ) -> OperationResponse[
        "capo_gamelift.types.describe_instances_output.DescribeInstancesOutput"
    ]:
        import capo_gamelift._operations.game_lift.describe_instances

        output, http_response = (
            capo_gamelift._operations.game_lift.describe_instances.describe_instances(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_gamelift.types.describe_instances_output.DescribeInstancesOutput",
    ) -> dict[str, Any]:
        import capo_gamelift.types.describe_instances_output

        return capo_gamelift.types.describe_instances_output.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("DescribeInstances", redact_output=_redact_output),
    )
    input_: capo_gamelift.types.describe_instances_input.DescribeInstancesInput = {}
    if fleet_id is not None:
        input_["fleet_id"] = fleet_id
    if instance_id is not None:
        input_["instance_id"] = instance_id
    if limit is not None:
        input_["limit"] = limit
    if next_token is not None:
        input_["next_token"] = next_token
    if location is not None:
        input_["location"] = location

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output