我正在尝试使用boto3编写python脚本以获取没有附加实例的输出LB名称 你能帮我吗?
答案 0 :(得分:0)
假设您正在使用网络或应用程序负载平衡器,这可能会有所帮助,
import boto3
my_client=boto3.client('elbv2', region_name='us-west-2', use_ssl='true')
response = my_client.describe_load_balancers()
for loadbalancer in (response["LoadBalancers"]):
my_targetgroups=my_client.describe_target_groups(LoadBalancerArn=loadbalancer["LoadBalancerArn"])
for my_targetgroup in my_targetgroups["TargetGroups"]:
response_target=my_client.describe_target_health(TargetGroupArn=my_targetgroup["TargetGroupArn"])
if response_target["TargetHealthDescriptions"]==[]:
print (loadbalancer["LoadBalancerName"])