查詢aws帳戶中全部的elb和其後端的instance狀態

 

#!/usr/bin/python
import sys
import boto3
client = boto3.client('elb')
def INSTANCEUNDERELB():
        response = client.describe_instance_health(
                LoadBalancerName=LBNAME,
        )
        INSTANCESTATUS=response.values()[0]
        print(len(INSTANCESTATUS))
        for i in INSTANCESTATUS:
                print(i.values()[0]+" "+i.values()[2]+" "+i.values()[3])python

ELBLIST = client.describe_load_balancers(
     PageSize=399
   )
ELBLIST=(ELBLIST.values())
#print(len(ELBLIST))
#print(ELBLIST[0])import

for ELEMENT in ELBLIST[0]:
        LBNAME=(ELEMENT["LoadBalancerName"])
        print("#####################")
        print(LBNAME)
        print("----")
        INSTANCEUNDERELB()cli

相關文章
相關標籤/搜索