4
我已经在cloudformatin中创建了一个堆栈,并希望获得输出。 我的代码是:如何阅读describe_stack输出属性
c = a.describe_stacks('Stack_id')
print c
返回对象
<boto.cloudformation.stack.StackSummary object at 0x1901d10>
我已经在cloudformatin中创建了一个堆栈,并希望获得输出。 我的代码是:如何阅读describe_stack输出属性
c = a.describe_stacks('Stack_id')
print c
返回对象
<boto.cloudformation.stack.StackSummary object at 0x1901d10>
到describe_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
对象。该堆栈的输出可用作outputs
属性stack
。该属性将包含一个Output
对象的列表,而该对象又具有key
,value
和description
属性。因此,这将打印所有输出:
for output in stack.outputs:
print('%s=%s (%s)' % (output.key, output.value, output.description))
的可能的复制[?从一宝途模板CloudFormation返回的输出(https://stackoverflow.com/questions/14163114/returning-the-outputs-从-A-cloudformation模板与 - 博托) –