Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions deployer/cloudformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,26 @@ def create_stack(self):
self.client.create_stack(**args)
self.create_waiter(start_time)

def wait_for_complete(self):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when does this get called?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's called in the initialization of the wrapping class.

try:
cloudformation = self.session.resource('cloudformation')
stack = cloudformation.Stack(self.stack_name)
stack.load()

if stack.stack_status == "CREATE_IN_PROGRESS":
self.create_waiter(datetime.now(pytz.utc))
elif stack.stack_status == "UPDATE_IN_PROGRESS":
self.update_waiter(datetime.now(pytz.utc))
elif stack.stack_status == "DELETE_IN_PROGRESS":
logger.info("Waiting for 'DELETE_COMPLETE'")
while stack.stack_status == "DELETE_IN_PROGRESS":
time.sleep(1)
stack.reload()
logger.debug(stack.stack_status)
except ClientError as e:
if e.response['Error']['Code'] != "ValidationError":
raise e


def create_waiter(self, start_time):
waiter = self.client.get_waiter('stack_create_complete')
Expand Down
19 changes: 19 additions & 0 deletions deployer/stack_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def __init__(self, profile, config_file, stack, disable_rollback=False, print_ev

self.validate_account()

if not self.accounts or not self.regions:
return super(StackSet, self).wait_for_complete()

@property
def current_instances(self):
result = self.client.list_stack_instances(StackSetName=self.stack_name)
Expand Down Expand Up @@ -69,6 +72,22 @@ def stack_set_status(self):
except ClientError:
return None

def wait_for_complete(self):
NextToken = None
response = self.client.list_stack_set_operations(StackSetName=self.stack_name)
for operation in response['Summaries']:
if operation['Status'] in ['RUNNING', 'STOPPING']:
self.stack_set_waiter(operation['OperationId'], "Waiting...")

while 'NextToken' in response:
response = self.client.list_stack_set_operations(StackSetName=self.stack_name, NextToken=NextToken)
NextToken = response['NextToken']
for operation in response['Summaries']:
if operation['Status'] in ['RUNNING', 'STOPPING']:
self.stack_set_waiter(operation['OperationId'], "Waiting...")



def validate_account(self):
current = self.current_account
if self.account is not None and current != self.account:
Expand Down