Add initial change set support
This commit is contained in:
parent
3a4ec1924b
commit
e393172e54
@ -2,7 +2,7 @@ import logging
|
|||||||
|
|
||||||
__author__ = 'Stefan Reimer'
|
__author__ = 'Stefan Reimer'
|
||||||
__email__ = 'stefan@zero-downtimet.net'
|
__email__ = 'stefan@zero-downtimet.net'
|
||||||
__version__ = '1.1.0'
|
__version__ = '1.1.1'
|
||||||
|
|
||||||
|
|
||||||
# Set up logging to ``/dev/null`` like a library is supposed to.
|
# Set up logging to ``/dev/null`` like a library is supposed to.
|
||||||
|
@ -46,12 +46,25 @@ def render(ctx, stack_name, multi):
|
|||||||
@click.option("--multi", is_flag=True, help="Allow more than one stack to match")
|
@click.option("--multi", is_flag=True, help="Allow more than one stack to match")
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def validate(ctx, stack_name, multi):
|
def validate(ctx, stack_name, multi):
|
||||||
|
""" Validates already rendered templates using cfn-lint """
|
||||||
stacks = _find_stacks(ctx, stack_name, multi)
|
stacks = _find_stacks(ctx, stack_name, multi)
|
||||||
|
|
||||||
for s in stacks:
|
for s in stacks:
|
||||||
s.validate()
|
s.validate()
|
||||||
|
|
||||||
|
|
||||||
|
@click.command()
|
||||||
|
@click.argument("stack_name")
|
||||||
|
@click.argument("change_set_name")
|
||||||
|
@click.pass_context
|
||||||
|
def create_change_set(ctx, stack_name, change_set_name):
|
||||||
|
""" Creates a change set for an existing stack """
|
||||||
|
stacks = _find_stacks(ctx, stack_name)
|
||||||
|
|
||||||
|
for s in stacks:
|
||||||
|
s.create_change_set(change_set_name)
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.argument("stack_name")
|
@click.argument("stack_name")
|
||||||
@click.option("--multi", is_flag=True, help="Allow more than one stack to match")
|
@click.option("--multi", is_flag=True, help="Allow more than one stack to match")
|
||||||
@ -143,7 +156,7 @@ def sort_stacks(ctx, stacks):
|
|||||||
assert not data, "A cyclic dependency exists amongst %r" % data
|
assert not data, "A cyclic dependency exists amongst %r" % data
|
||||||
|
|
||||||
|
|
||||||
def _find_stacks(ctx, stack_name,multi):
|
def _find_stacks(ctx, stack_name,multi=False):
|
||||||
cb = ctx.obj['cb']
|
cb = ctx.obj['cb']
|
||||||
|
|
||||||
# ALL acts ass config and multi=True
|
# ALL acts ass config and multi=True
|
||||||
@ -169,6 +182,7 @@ cli.add_command(validate)
|
|||||||
cli.add_command(provision)
|
cli.add_command(provision)
|
||||||
cli.add_command(delete)
|
cli.add_command(delete)
|
||||||
cli.add_command(clean)
|
cli.add_command(clean)
|
||||||
|
cli.add_command(create_change_set)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
cli(obj={})
|
cli(obj={})
|
||||||
|
@ -366,6 +366,28 @@ class Stack(object):
|
|||||||
return self._wait_for_completion()
|
return self._wait_for_completion()
|
||||||
|
|
||||||
|
|
||||||
|
def create_change_set(self, change_set_name):
|
||||||
|
""" Creates a Change Set with the name ``change_set_name``. """
|
||||||
|
|
||||||
|
# Prepare parameters
|
||||||
|
self.resolve_parameters()
|
||||||
|
self.write_parameter_file()
|
||||||
|
|
||||||
|
if not self.cfn_template:
|
||||||
|
self.read_template_file()
|
||||||
|
|
||||||
|
logger.info('Creating change set {0} for stack {1}'.format(change_set_name, self.stackname))
|
||||||
|
response = self.connection_manager.call('cloudformation', 'create_change_set',
|
||||||
|
{'StackName':self.stackname,
|
||||||
|
'ChangeSetName': change_set_name,
|
||||||
|
'TemplateBody':self.cfn_template,
|
||||||
|
'Parameters':self.cfn_parameters,
|
||||||
|
'Tags':[ {"Key": str(k), "Value": str(v)} for k, v in self.tags.items() ],
|
||||||
|
'Capabilities':['CAPABILITY_IAM', 'CAPABILITY_NAMED_IAM']},
|
||||||
|
profile=self.profile, region=self.region)
|
||||||
|
return self._wait_for_completion()
|
||||||
|
|
||||||
|
|
||||||
def describe(self):
|
def describe(self):
|
||||||
"""
|
"""
|
||||||
Returns the a description of the stack.
|
Returns the a description of the stack.
|
||||||
|
Loading…
Reference in New Issue
Block a user