0
我想獲取AWS堆棧詳細信息,堆棧id,每個堆棧的層數,每個層的實例數量以及使用python腳本的實例數量。請有人幫我一下。用於獲取aws堆棧層實例和標籤的詳細信息的Python腳本
我想獲取AWS堆棧詳細信息,堆棧id,每個堆棧的層數,每個層的實例數量以及使用python腳本的實例數量。請有人幫我一下。用於獲取aws堆棧層實例和標籤的詳細信息的Python腳本
#!/usr/bin/python
import boto3
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
print ("\n")
st_name = raw_input("What is STACK_NAME name? :: ")
stack_name = boto3.client('opsworks')
stacs = stack_name.describe_stacks()
for st in stacs['Stacks']:
stname = st['Name']
if st_name == stname :
print bcolors.OKBLUE + ("\nSTACK ID FOR THIS STACK IS :: \n")
print bcolors.WARNING + st['StackId']
stid = st['StackId']
print bcolors.FAIL + (" \nLayers Attached with this STACK and their ID's are :")
print bcolors.ENDC
layr = stack_name.describe_layers(StackId=stid)
for lr in layr['Layers']:
print "LAYER NAME :: " + bcolors.OKGREEN +lr['Name'] + bcolors.ENDC + " LAYER ID is :: " + bcolors.OKBLUE + lr['LayerId']
輸出示例:
檢查下面的鏈接以查看示例輸出:https://s17.postimg.org/l6fhb8uu7/Screen_Shot_2017-11-26_at_2.05.38_AM.png –
什麼你試過嗎? – Gammer