Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
stack_name = self.get_stack_name(stack)
stack_status = self.get_stack_status(stack)
if self.is_stack_in_progress(stack):
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 build.should_submit(stack):
return NotSubmittedStatus()
if not build.should_update(stack):
return NotUpdatedStatus()
provider = self.build_provider(stack)
provider_stack = provider.get_stack(stack.fqn)
# get the current stack template & params from AWS
try:
[old_template, old_params] = provider.get_stack_info(
provider_stack)
except exceptions.StackDoesNotExist:
old_template = None
old_params = {}
stack.resolve(self.context, provider)
# generate our own template & params
parameters = self.build_parameters(stack)
new_params = dict()
for p in parameters:
new_params[p['ParameterKey']] = p['ParameterValue']
new_template = stack.blueprint.rendered
new_stack = normalize_json(new_template)
output = ["============== Stack: %s ==============" % (stack.name,)]
# If this is a completely new template dump our params & stack
if not old_template:
output.extend(self._build_new_template(new_stack, parameters))
if include_verbose and approve == "v":
if params_diff:
logger.info(
"Full changeset:\n\n%s\n%s",
format_params_diff(params_diff),
yaml.safe_dump(full_changeset),
)
else:
logger.info(
"Full changeset:\n%s",
yaml.safe_dump(full_changeset),
)
return ask_for_approval()
elif approve != "y":
raise exceptions.CancelExecution
environment (Optional[dict]): any environment values that should be
passed to the config
Returns:
dict: the stacker configuration populated with any values passed from
the environment
"""
t = Template(raw_config)
buff = StringIO()
if not environment:
environment = {}
try:
buff.write(t.substitute(environment))
except KeyError, e:
raise exceptions.MissingEnvironment(e.args[0])
except ValueError:
# Support "invalid" placeholders for lookup placeholders.
buff.write(t.safe_substitute(environment))
buff.seek(0)
config = yaml.load(buff)
return config
if include_verbose and approve == "v":
if params_diff:
logger.info(
"Full changeset:\n\n%s\n%s",
format_params_diff(params_diff),
yaml.safe_dump(full_changeset),
)
else:
logger.info(
"Full changeset:\n%s",
yaml.safe_dump(full_changeset),
)
return ask_for_approval()
elif approve != "y":
raise exceptions.CancelExecution