在 Load Balancer 中打印实例的状态

Printing the status of instance in Load Balancer

我想打印连接到负载均衡器的实例的状态。(InService/OutOfService)。 我怎样才能使用 Boto3 做到这一点。我已附上屏幕截图以指定我需要打印的内容。 提前致谢。

describe_instance_health - 描述指定实例相对于指定负载均衡器的状态

import boto3
client = boto3.client("elb")
response = client.describe_instance_health(LoadBalancerName='testname')
for instance in response['InstanceStates']:
    print(instance['InstanceId'],instance['State'])