Skip to content

Instantly share code, notes, and snippets.

@tomkukral
Created November 1, 2017 13:44
Show Gist options
  • Select an option

  • Save tomkukral/a8464d62bdee72fc1e6d585d55e6264f to your computer and use it in GitHub Desktop.

Select an option

Save tomkukral/a8464d62bdee72fc1e6d585d55e6264f to your computer and use it in GitHub Desktop.
List CloudFormation stacks
#!/usr/bin/env python3
import boto3
from pprint import pprint
session = boto3.Session(profile_name='mi')
client = session.client('cloudformation')
stacks = client.describe_stacks()
for stack in stacks['Stacks']:
#pprint(stack)
name = stack['StackName']
status = stack['StackStatus']
salt = ''
created_at = stack['CreationTime'].isoformat()
for output in stack['Outputs']:
if output['OutputKey'] == 'SaltMasterIP':
salt = output['OutputValue']
print(name, status, salt, created_at)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment