Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
waitfunc = WAITERS.get(self.get_stack_status(stack))
# Wait for the stack to transition from
# UPDATE_IN_PROGRESS/CREATE_IN_PROGRESS to
# UPDATE_COMPLETE/CREATE_COMPLETE
if wait and waitfunc:
waiter = self.cloudformation.get_waiter(waitfunc)
waiter.wait(StackName=stack_name)
return True
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Update already in-progress')
if not self.is_stack_recreatable(stack):
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Unsupported state for re-creation')
if not self.recreate_failed:
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Stack re-creation is disabled. Run stacker again with the '
'--recreate-failed option to force it to be deleted and '
'created from scratch.')
stack_tags = self.get_stack_tags(stack)
if not check_tags_contain(stack_tags, tags):
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Tags differ from current configuration, possibly not created '
'with stacker')
if wait and waitfunc:
waiter = self.cloudformation.get_waiter(waitfunc)
waiter.wait(StackName=stack_name)
return True
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Update already in-progress')
if not self.is_stack_recreatable(stack):
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Unsupported state for re-creation')
if not self.recreate_failed:
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Stack re-creation is disabled. Run stacker again with the '
'--recreate-failed option to force it to be deleted and '
'created from scratch.')
stack_tags = self.get_stack_tags(stack)
if not check_tags_contain(stack_tags, tags):
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Tags differ from current configuration, possibly not created '
'with stacker')
if self.interactive:
sys.stdout.write(
'The \"%s\" stack is in a failed state (%s).\n'
'It cannot be updated, but it can be deleted and re-created.\n'
if self.is_stack_destroyed(stack):
return False
elif self.is_stack_completed(stack):
return True
stack_name = self.get_stack_name(stack)
stack_status = self.get_stack_status(stack)
if self.is_stack_in_progress(stack):
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Update already in-progress')
if not self.is_stack_recreatable(stack):
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Unsupported state for re-creation')
if not self.recreate_failed:
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Stack re-creation is disabled. Run stacker again with the '
'--recreate-failed option to force it to be deleted and '
'created from scratch.')
stack_tags = self.get_stack_tags(stack)
if not check_tags_contain(stack_tags, tags):
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Tags differ from current configuration, possibly not created '
'with stacker')
if not self.is_stack_recreatable(stack):
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Unsupported state for re-creation')
if not self.recreate_failed:
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Stack re-creation is disabled. Run stacker again with the '
'--recreate-failed option to force it to be deleted and '
'created from scratch.')
stack_tags = self.get_stack_tags(stack)
if not check_tags_contain(stack_tags, tags):
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Tags differ from current configuration, possibly not created '
'with stacker')
if self.interactive:
sys.stdout.write(
'The \"%s\" stack is in a failed state (%s).\n'
'It cannot be updated, but it can be deleted and re-created.\n'
'All its current resources will IRREVERSIBLY DESTROYED.\n'
'Proceed carefully!\n\n' % (stack_name, stack_status))
sys.stdout.flush()
ask_for_approval(include_verbose=False)
logger.warn('Destroying stack \"%s\" for re-creation', stack_name)
self.destroy_stack(stack)
def __init__(self, stack_name, stack_status, reason, *args, **kwargs):
self.stack_name = stack_name
self.stack_status = stack_status
message = ("Stack: \"%s\" cannot be updated nor re-created from state "
"%s: %s" % (stack_name, stack_status, reason))
super(StackUpdateBadStatus, self).__init__(message, *args, **kwargs)
stack_name = self.get_stack_name(stack)
stack_status = self.get_stack_status(stack)
if self.is_stack_in_progress(stack):
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Update already in-progress')
if not self.is_stack_recreatable(stack):
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Unsupported state for re-creation')
if not self.recreate_failed:
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Stack re-creation is disabled. Run stacker again with the '
'--recreate-failed option to force it to be deleted and '
'created from scratch.')
stack_tags = self.get_stack_tags(stack)
if not check_tags_contain(stack_tags, tags):
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Tags differ from current configuration, possibly not created '
'with stacker')
if self.interactive:
sys.stdout.write(
'The \"%s\" stack is in a failed state (%s).\n'
'It cannot be updated, but it can be deleted and re-created.\n'
if not self.is_stack_recreatable(stack):
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Unsupported state for re-creation')
if not self.recreate_failed:
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Stack re-creation is disabled. Run stacker again with the '
'--recreate-failed option to force it to be deleted and '
'created from scratch.')
stack_tags = self.get_stack_tags(stack)
if not check_tags_contain(stack_tags, tags):
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Tags differ from current configuration, possibly not created '
'with stacker')
if self.interactive:
sys.stdout.write(
'The \"%s\" stack is in a failed state (%s).\n'
'It cannot be updated, but it can be deleted and re-created.\n'
'All its current resources will IRREVERSIBLY DESTROYED.\n'
'Proceed carefully!\n\n' % (stack_name, stack_status))
sys.stdout.flush()
ask_for_approval(include_verbose=False)
logger.warn('Destroying stack \"%s\" for re-creation', stack_name)
self.destroy_stack(stack)
Returns:
bool: True if the stack can be updated, False if it must be
re-created
"""
if self.is_stack_destroyed(stack):
return False
elif self.is_stack_completed(stack):
return True
stack_name = self.get_stack_name(stack)
stack_status = self.get_stack_status(stack)
if self.is_stack_in_progress(stack):
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Update already in-progress')
if not self.is_stack_recreatable(stack):
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Unsupported state for re-creation')
if not self.recreate_failed:
raise exceptions.StackUpdateBadStatus(
stack_name, stack_status,
'Stack re-creation is disabled. Run stacker again with the '
'--recreate-failed option to force it to be deleted and '
'created from scratch.')
stack_tags = self.get_stack_tags(stack)