Question

i have created a stack in cloudformatin and wants to get the output. My code is:

c = a.describe_stacks('Stack_id') 
print c

Returns an object

<boto.cloudformation.stack.StackSummary object at 0x1901d10>
Was it helpful?

Solution

The call to describe_stacks should return a list of Stack objects, not a single StackSummary object. Let's just walk through a complete example to avoid confusion.

First, do something like this:

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

At this point the variable stack is a Stack object. The outputs of the stack are available as the outputs attribute of stack. This attribute will contain a list of Output objects which, in turn, have a key, value, and description attribute. So, this would print all of the outputs:

for output in stack.outputs:
    print('%s=%s (%s)' % (output.key, output.value, output.description))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top