Repository: getmoto/moto

Issue:
DescribeInstanceHealth should return State: Unknown for unregistered instances.
The test below fails with `AssertionError: assert 'InService' == 'Unknown'`.
I will provide a PR if you agree that this is something that should be fixed :) 

```python3
@mock_ec2
@mock_elb
def test_failing_test_case():
    elb = boto3.client()
    ec2 = boto3.client()
    # Create an instance (we will not use it)
    instance_id = ec2.run_instances(MinCount=1, MaxCount=1)['Instances'][0]['InstanceId']
    # Create a classic load balancer, without any registered instances
    lb_name = "my_load_balancer"
    elb.create_load_balancer(
        Listeners=[{
            'InstancePort': 80,
            'LoadBalancerPort': 8080,
            'Protocol': 'HTTP'
        }],
        LoadBalancerName=lb_name,
    )
    # The instance was never registered in the load balancer...
    response = elb.describe_instance_health(LoadBalancerName=lb_name,
                                            Instances=[{'InstanceId': instance_id}])
    # and therefore should not be 'InService'.
    assert response['InstanceStates'][0]['State'] == "Unknown"
```

Edit: I made the PR anyway.


Discussion:

Resolving patch:
diff --git a/moto/elb/responses.py b/moto/elb/responses.py
--- a/moto/elb/responses.py
+++ b/moto/elb/responses.py
@@ -259,12 +259,22 @@ def set_load_balancer_policies_for_backend_server(self):
 
     def describe_instance_health(self):
         load_balancer_name = self._get_param('LoadBalancerName')
-        instance_ids = [list(param.values())[0] for param in self._get_list_prefix('Instances.member')]
-        if len(instance_ids) == 0:
-            instance_ids = self.elb_backend.get_load_balancer(
-                load_balancer_name).instance_ids
+        provided_instance_ids = [
+            list(param.values())[0]
+            for param in self._get_list_prefix('Instances.member')
+        ]
+        registered_instances_id = self.elb_backend.get_load_balancer(
+            load_balancer_name).instance_ids
+        if len(provided_instance_ids) == 0:
+            provided_instance_ids = registered_instances_id
         template = self.response_template(DESCRIBE_INSTANCE_HEALTH_TEMPLATE)
-        return template.render(instance_ids=instance_ids)
+        instances = []
+        for instance_id in provided_instance_ids:
+            state = "InService" \
+                if instance_id in registered_instances_id\
+                else "Unknown"
+            instances.append({"InstanceId": instance_id, "State": state})
+        return template.render(instances=instances)
 
     def add_tags(self):
 
@@ -689,11 +699,11 @@ def _add_tags(self, elb):
 DESCRIBE_INSTANCE_HEALTH_TEMPLATE = """<DescribeInstanceHealthResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
   <DescribeInstanceHealthResult>
     <InstanceStates>
-      {% for instance_id in instance_ids %}
+      {% for instance in instances %}
       <member>
         <Description>N/A</Description>
-        <InstanceId>{{ instance_id }}</InstanceId>
-        <State>InService</State>
+        <InstanceId>{{ instance['InstanceId'] }}</InstanceId>
+        <State>{{ instance['State'] }}</State>
         <ReasonCode>N/A</ReasonCode>
       </member>
       {% endfor %}


Test patch:
diff --git a/tests/test_elb/test_elb.py b/tests/test_elb/test_elb.py
--- a/tests/test_elb/test_elb.py
+++ b/tests/test_elb/test_elb.py
@@ -723,6 +723,40 @@ def test_describe_instance_health():
     instances_health[0].state.should.equal('InService')
 
 
+@mock_ec2
+@mock_elb
+def test_describe_instance_health_boto3():
+    elb = boto3.client('elb', region_name="us-east-1")
+    ec2 = boto3.client('ec2', region_name="us-east-1")
+    instances = ec2.run_instances(MinCount=2, MaxCount=2)['Instances']
+    lb_name = "my_load_balancer"
+    elb.create_load_balancer(
+        Listeners=[{
+            'InstancePort': 80,
+            'LoadBalancerPort': 8080,
+            'Protocol': 'HTTP'
+        }],
+        LoadBalancerName=lb_name,
+    )
+    elb.register_instances_with_load_balancer(
+        LoadBalancerName=lb_name,
+        Instances=[{'InstanceId': instances[0]['InstanceId']}]
+    )
+    instances_health = elb.describe_instance_health(
+        LoadBalancerName=lb_name,
+        Instances=[{'InstanceId': instance['InstanceId']} for instance in instances]
+    )
+    instances_health['InstanceStates'].should.have.length_of(2)
+    instances_health['InstanceStates'][0]['InstanceId'].\
+        should.equal(instances[0]['InstanceId'])
+    instances_health['InstanceStates'][0]['State'].\
+        should.equal('InService')
+    instances_health['InstanceStates'][1]['InstanceId'].\
+        should.equal(instances[1]['InstanceId'])
+    instances_health['InstanceStates'][1]['State'].\
+        should.equal('Unknown')
+
+
 @mock_elb
 def test_add_remove_tags():
     client = boto3.client('elb', region_name='us-east-1')