Skip to content

Commit

Permalink
adding ShouldDeleteRollbackComplete
Browse files Browse the repository at this point in the history
  • Loading branch information
eamonnfaherty committed Sep 2, 2020
1 parent 14eb7ec commit b9c5873
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions betterboto/cloudformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def get_hash_for_template(template):
return "{}{}".format('a', hasher.hexdigest())


def create_or_update(self, ShouldUseChangeSets=True, **kwargs):
def create_or_update(self, ShouldUseChangeSets=True, ShouldDeleteRollbackComplete=False, **kwargs):
"""
For the given template and stack name, this method will create a stack if it doesnt already exist otherwise it will
generate a changeset and then execute it. This method will wait for the operation to complete before returning and
Expand All @@ -35,9 +35,11 @@ def create_or_update(self, ShouldUseChangeSets=True, **kwargs):
describe_stack = self.describe_stacks(
StackName=stack_name
)
if describe_stack['Stacks'][0]['StackStatus'] == 'ROLLBACK_COMPLETE':
logger.info("Stack with id {} previously failed to create, deleting".format(stack_name))
ensure_deleted(self, stack_name)
if ShouldDeleteRollbackComplete:
if len(describe_stack.get('Stacks', []) > 0) and describe_stack.get('Stacks')[0].get("StackStatus", "") == "ROLLBACK_COMPLETE":
logger.info("Stack with id {} is ROLLBACK_COMPLETE, deleting".format(stack_name))
ensure_deleted(self, stack_name)
is_first_run = True
else:
is_first_run = False
except self.exceptions.ClientError as e:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setuptools.setup(
name="better-boto",
version="0.30.0",
version="0.31.0",
author="Eamonn Faherty",
author_email="python-packages@designandsolve.co.uk",
description="Helpers to make using boto3 more enjoyable",
Expand Down

0 comments on commit b9c5873

Please sign in to comment.