in servicecatalog_puppet/workflow/stack/provision_stack_task.py [0:0]
def ensure_stack_is_in_complete_status(self):
current_stack = dict(StackStatus="DoesntExist")
with self.spoke_regional_client("cloudformation") as cloudformation:
try:
paginator = cloudformation.get_paginator("describe_stacks")
for page in paginator.paginate(StackName=self.stack_name_to_use,):
for stack in page.get("Stacks", []):
status = stack.get("StackStatus")
if status in [
"CREATE_IN_PROGRESS",
"ROLLBACK_IN_PROGRESS",
"DELETE_IN_PROGRESS",
"UPDATE_IN_PROGRESS",
"UPDATE_COMPLETE_CLEANUP_IN_PROGRESS",
"UPDATE_ROLLBACK_IN_PROGRESS",
"UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS",
"IMPORT_ROLLBACK_IN_PROGRESS",
"REVIEW_IN_PROGRESS",
"IMPORT_IN_PROGRESS",
"CREATE_FAILED",
"ROLLBACK_FAILED",
"DELETE_FAILED",
"UPDATE_ROLLBACK_FAILED",
"IMPORT_ROLLBACK_FAILED",
]:
while status not in [
"ROLLBACK_COMPLETE",
"CREATE_COMPLETE",
"UPDATE_ROLLBACK_COMPLETE",
"DELETE_COMPLETE",
"UPDATE_COMPLETE",
"IMPORT_COMPLETE",
"IMPORT_ROLLBACK_COMPLETE",
]:
time.sleep(5)
sub_paginator = cloudformation.get_paginator(
"describe_stacks"
)
for sub_page in sub_paginator.paginate(
StackName=stack.get("StackId"),
):
for sub_stack in sub_page.get("Stacks", []):
status = sub_stack.get("StackStatus")
current_stack = stack
except ClientError as error:
if (
error.response["Error"]["Message"]
!= f"Stack with id {self.stack_name_to_use} does not exist"
):
raise error
return current_stack