Sur*_*ala 6 python stack boto amazon-web-services aws-cloudformation
我已经在cloudformatin中创建了一个堆栈并希望得到输出.我的代码是:
c = a.describe_stacks('Stack_id')
print c
Run Code Online (Sandbox Code Playgroud)
返回一个对象
<boto.cloudformation.stack.StackSummary object at 0x1901d10>
Run Code Online (Sandbox Code Playgroud)
gar*_*aat 10
调用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
Run Code Online (Sandbox Code Playgroud)
此时变量stack是一个Stack对象.堆栈的输出可用作outputs属性stack.此属性将包含一个列表Output,反过来,有一个对象key,value和description属性.因此,这将打印所有输出:
for output in stack.outputs:
print('%s=%s (%s)' % (output.key, output.value, output.description))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5467 次 |
| 最近记录: |