File tree Expand file tree Collapse file tree 3 files changed +56
-1
lines changed
Expand file tree Collapse file tree 3 files changed +56
-1
lines changed Original file line number Diff line number Diff line change 1+ import logging
2+
3+ from .base import BaseAction
4+ from .. import exceptions
5+
6+ logger = logging .getLogger (__name__ )
7+
8+
9+ class Action (BaseAction ):
10+ """Get information on CloudFormation stacks.
11+
12+ Displays the outputs for the set of CloudFormation stacks.
13+
14+ """
15+
16+ def run (self , * args , ** kwargs ):
17+ logger .info ('Outputs for stacks: %s' , self .context .get_fqn ())
18+ for stack in self .context .get_stacks ():
19+ try :
20+ provider_stack = self .provider .get_stack (stack .fqn )
21+ except exceptions .StackDoesNotExist :
22+ logger .info ('Stack "%s" does not exist.' % (stack .fqn ,))
23+ continue
24+
25+ logger .info ('%s:' , stack .fqn )
26+ for output in provider_stack .outputs :
27+ logger .info ('\t %s: %s' , output .key , output .value )
Original file line number Diff line number Diff line change 22
33from .build import Build
44from .destroy import Destroy
5+ from .info import Info
56from .base import BaseCommand
67from ...context import Context
78from ...providers import aws
1011class Stacker (BaseCommand ):
1112
1213 name = 'stacker'
13- subcommands = (Build , Destroy )
14+ subcommands = (Build , Destroy , Info )
1415
1516 def configure (self , options , ** kwargs ):
1617 super (Stacker , self ).configure (options , ** kwargs )
Original file line number Diff line number Diff line change 1+ """Gets information on the CloudFormation stacks based on the given config."""
2+
3+ from .base import BaseCommand
4+ from ...actions import info
5+
6+
7+ class Info (BaseCommand ):
8+
9+ name = 'info'
10+ description = __doc__
11+
12+ def add_arguments (self , parser ):
13+ super (Info , self ).add_arguments (parser )
14+ parser .add_argument ("--stacks" , action = "append" ,
15+ metavar = "STACKNAME" , type = str ,
16+ help = "Only work on the stacks given. Can be "
17+ "specified more than once. If not specified "
18+ "then stacker will work on all stacks in the "
19+ "config file." )
20+
21+ def run (self , options , ** kwargs ):
22+ super (Info , self ).run (options , ** kwargs )
23+ action = info .Action (options .context , provider = options .provider )
24+ action .execute ()
25+
26+ def get_context_kwargs (self , options , ** kwargs ):
27+ return {'stack_names' : options .stacks }
You can’t perform that action at this time.
0 commit comments