in source/state_machine_handler.py [0:0]
def describe_stack_set_operation(self):
self.logger.info("Executing: " + self.__class__.__name__ + "/"
+ inspect.stack()[0][3])
self.logger.info(self.params)
self.event.update({'RetryDeleteFlag': False})
stack_set = StackSet(self.logger)
response = stack_set.describe_stack_set_operation(
self.params.get('StackSetName'),
self.event.get('OperationId'))
self.logger.info(response)
operation_status = response.get('StackSetOperation', {}).get('Status')
self.logger.info("Operation Status: {}".format(operation_status))
if operation_status == 'FAILED':
account_id = self.params.get('AccountList')[0] \
if type(self.params.get('AccountList')) is list \
else None
if account_id:
for region in self.params.get('RegionList'):
self.logger.info("Account: {} - describing stack "
"instance in {} region"
.format(account_id, region))
try:
resp = stack_set.describe_stack_instance(
self.params.get('StackSetName'),
account_id,
region)
self.event.update({region: resp.get(
'StackInstance', {}).get('StatusReason')})
except ClientError as e:
# When CFN has triggered StackInstance delete and
# the SCP is still attached (due to race condition)
# , then it fails to delete the stack and StackSet
# throws the StackInstanceNotFoundException
# exception back, the CFN stack in target account
# ends up with 'DELETE_FAILED' state
# so it should try again
if e.response['Error']['Code'] == \
'StackInstanceNotFoundException' and \
self.event.get('RequestType') == 'Delete':
self.logger.exception(
"Caught exception"
"'StackInstanceNotFoundException',"
"sending the flag to go back to "
" Delete Stack Instances stage...")
self.event.update({'RetryDeleteFlag': True})
operation_status = response.get('StackSetOperation', {}).get('Status')
self.event.update({'OperationStatus': operation_status})
return self.event