Python 如何读取描述_堆栈输出属性
我已经在cloudformatin中创建了一个堆栈,并希望获得输出。 我的代码是: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
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))
可能重复的