list_instances

list_instances(**kwargs)

Provides information for all active EC2 instances and EC2 instances terminated in the last 30 days, up to a maximum of 2,000. EC2 instances in any of the following states are considered active: AWAITING_FULFILLMENT, PROVISIONING, BOOTSTRAPPING, RUNNING.

See also: AWS API Documentation

Request Syntax

response = client.list_instances(
    ClusterId='string',
    InstanceGroupId='string',
    InstanceGroupTypes=[
        'MASTER'|'CORE'|'TASK',
    ],
    InstanceFleetId='string',
    InstanceFleetType='MASTER'|'CORE'|'TASK',
    InstanceStates=[
        'AWAITING_FULFILLMENT'|'PROVISIONING'|'BOOTSTRAPPING'|'RUNNING'|'TERMINATED',
    ],
    Marker='string'
)
Parameters
  • ClusterId (string) --

    [REQUIRED]

    The identifier of the cluster for which to list the instances.

  • InstanceGroupId (string) -- The identifier of the instance group for which to list the instances.
  • InstanceGroupTypes (list) --

    The type of instance group for which to list the instances.

    • (string) --
  • InstanceFleetId (string) -- The unique identifier of the instance fleet.
  • InstanceFleetType (string) -- The node type of the instance fleet. For example MASTER, CORE, or TASK.
  • InstanceStates (list) --

    A list of instance states that will filter the instances returned with this request.

    • (string) --
  • Marker (string) -- The pagination token that indicates the next set of results to retrieve.
Return type

dict

Returns

Response Syntax

{
    'Instances': [
        {
            'Id': 'string',
            'Ec2InstanceId': 'string',
            'PublicDnsName': 'string',
            'PublicIpAddress': 'string',
            'PrivateDnsName': 'string',
            'PrivateIpAddress': 'string',
            'Status': {
                'State': 'AWAITING_FULFILLMENT'|'PROVISIONING'|'BOOTSTRAPPING'|'RUNNING'|'TERMINATED',
                'StateChangeReason': {
                    'Code': 'INTERNAL_ERROR'|'VALIDATION_ERROR'|'INSTANCE_FAILURE'|'BOOTSTRAP_FAILURE'|'CLUSTER_TERMINATED',
                    'Message': 'string'
                },
                'Timeline': {
                    'CreationDateTime': datetime(2015, 1, 1),
                    'ReadyDateTime': datetime(2015, 1, 1),
                    'EndDateTime': datetime(2015, 1, 1)
                }
            },
            'InstanceGroupId': 'string',
            'InstanceFleetId': 'string',
            'Market': 'ON_DEMAND'|'SPOT',
            'InstanceType': 'string',
            'EbsVolumes': [
                {
                    'Device': 'string',
                    'VolumeId': 'string'
                },
            ]
        },
    ],
    'Marker': 'string'
}

Response Structure

  • (dict) --

    This output contains the list of instances.

    • Instances (list) --

      The list of instances for the cluster and given filters.

      • (dict) --

        Represents an EC2 instance provisioned as part of cluster.

        • Id (string) --

          The unique identifier for the instance in Amazon EMR.

        • Ec2InstanceId (string) --

          The unique identifier of the instance in Amazon EC2.

        • PublicDnsName (string) --

          The public DNS name of the instance.

        • PublicIpAddress (string) --

          The public IP address of the instance.

        • PrivateDnsName (string) --

          The private DNS name of the instance.

        • PrivateIpAddress (string) --

          The private IP address of the instance.

        • Status (dict) --

          The current status of the instance.

          • State (string) --

            The current state of the instance.

          • StateChangeReason (dict) --

            The details of the status change reason for the instance.

            • Code (string) --

              The programmable code for the state change reason.

            • Message (string) --

              The status change reason description.

          • Timeline (dict) --

            The timeline of the instance status over time.

            • CreationDateTime (datetime) --

              The creation date and time of the instance.

            • ReadyDateTime (datetime) --

              The date and time when the instance was ready to perform tasks.

            • EndDateTime (datetime) --

              The date and time when the instance was terminated.

        • InstanceGroupId (string) --

          The identifier of the instance group to which this instance belongs.

        • InstanceFleetId (string) --

          The unique identifier of the instance fleet to which an EC2 instance belongs.

        • Market (string) --

          The instance purchasing option. Valid values are ON_DEMAND or SPOT .

        • InstanceType (string) --

          The EC2 instance type, for example m3.xlarge .

        • EbsVolumes (list) --

          The list of Amazon EBS volumes that are attached to this instance.

          • (dict) --

            EBS block device that's attached to an EC2 instance.

            • Device (string) --

              The device name that is exposed to the instance, such as /dev/sdh.

            • VolumeId (string) --

              The volume identifier of the EBS volume.

    • Marker (string) --

      The pagination token that indicates the next set of results to retrieve.

Exceptions

  • EMR.Client.exceptions.InternalServerException
  • EMR.Client.exceptions.InvalidRequestException