describe_instance_health

describe_instance_health(**kwargs)

Describes the state of the specified instances with respect to the specified load balancer. If no instances are specified, the call describes the state of all instances that are currently registered with the load balancer. If instances are specified, their state is returned even if they are no longer registered with the load balancer. The state of terminated instances is not returned.

See also: AWS API Documentation

Request Syntax

response = client.describe_instance_health(
    LoadBalancerName='string',
    Instances=[
        {
            'InstanceId': 'string'
        },
    ]
)
Parameters
  • LoadBalancerName (string) --

    [REQUIRED]

    The name of the load balancer.

  • Instances (list) --

    The IDs of the instances.

    • (dict) --

      The ID of an EC2 instance.

      • InstanceId (string) --

        The instance ID.

Return type

dict

Returns

Response Syntax

{
    'InstanceStates': [
        {
            'InstanceId': 'string',
            'State': 'string',
            'ReasonCode': 'string',
            'Description': 'string'
        },
    ]
}

Response Structure

  • (dict) --

    Contains the output for DescribeInstanceHealth.

    • InstanceStates (list) --

      Information about the health of the instances.

      • (dict) --

        Information about the state of an EC2 instance.

        • InstanceId (string) --

          The ID of the instance.

        • State (string) --

          The current state of the instance.

          Valid values: InService | OutOfService | Unknown

        • ReasonCode (string) --

          Information about the cause of OutOfService instances. Specifically, whether the cause is Elastic Load Balancing or the instance.

          Valid values: ELB | Instance | N/A

        • Description (string) --

          A description of the instance state. This string can contain one or more of the following messages.

          • N/A
          • A transient error occurred. Please try again later.
          • Instance has failed at least the UnhealthyThreshold number of health checks consecutively.
          • Instance has not passed the configured HealthyThreshold number of health checks consecutively.
          • Instance registration is still in progress.
          • Instance is in the EC2 Availability Zone for which LoadBalancer is not configured to route traffic to.
          • Instance is not currently registered with the LoadBalancer.
          • Instance deregistration currently in progress.
          • Disable Availability Zone is currently in progress.
          • Instance is in pending state.
          • Instance is in stopped state.
          • Instance is in terminated state.

Exceptions

  • ElasticLoadBalancing.Client.exceptions.AccessPointNotFoundException
  • ElasticLoadBalancing.Client.exceptions.InvalidEndPointException

Examples

This example describes the health of the instances for the specified load balancer.

response = client.describe_instance_health(
    LoadBalancerName='my-load-balancer',
)

print(response)

Expected Output:

{
    'InstanceStates': [
        {
            'Description': 'N/A',
            'InstanceId': 'i-207d9717',
            'ReasonCode': 'N/A',
            'State': 'InService',
        },
        {
            'Description': 'N/A',
            'InstanceId': 'i-afefb49b',
            'ReasonCode': 'N/A',
            'State': 'InService',
        },
    ],
    'ResponseMetadata': {
        '...': '...',
    },
}