Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/355.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何读取描述_堆栈输出属性_Python_Amazon Web Services_Stack_Boto_Amazon Cloudformation - Fatal编程技术网

Python 如何读取描述_堆栈输出属性

Python 如何读取描述_堆栈输出属性,python,amazon-web-services,stack,boto,amazon-cloudformation,Python,Amazon Web Services,Stack,Boto,Amazon Cloudformation,我已经在cloudformatin中创建了一个堆栈,并希望获得输出。 我的代码是: c = a.describe_stacks('Stack_id') print c 返回一个对象 <boto.cloudformation.stack.StackSummary object at 0x1901d10> 调用descripe\u stacks应该返回Stack对象的列表,而不是单个StackSummary对象。让我们浏览一个完整的示例,以避免混淆 首先,像这样做: import

我已经在cloudformatin中创建了一个堆栈,并希望获得输出。 我的代码是:

c = a.describe_stacks('Stack_id') 
print c
返回一个对象

<boto.cloudformation.stack.StackSummary object at 0x1901d10>

调用
descripe\u stacks
应该返回
Stack
对象的列表,而不是单个
StackSummary
对象。让我们浏览一个完整的示例,以避免混淆

首先,像这样做:

import boto.cloudformation
conn = boto.cloudformation.connect_to_region('us-west-2')  # or your favorite region
stacks = conn.describe_stacks('MyStackID')
if len(stacks) == 1:
    stack = stacks[0]
else:
    # Raise an exception or something because your stack isn't there
此时,变量
stack
stack
对象。堆栈的输出作为
堆栈的
输出属性提供。此属性将包含
输出
对象的列表,这些对象依次具有
描述
属性。因此,这将打印所有输出:

for output in stack.outputs:
    print('%s=%s (%s)' % (output.key, output.value, output.description))
可能重复的