我想获取AWS堆栈详细信息,堆栈ID,每个堆栈的层数,没有每个层的实例及其使用python脚本的标签。有人可以帮我。
答案 0 :(得分:-2)
#!/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']
示例输出: