in control-tower-account-factory/src/handler.py [0:0]
def __init__(self, account_id, provision_products, update_products, deployed_products, failed_products, skipped_products, execution_account_id, iteration, max_iterations, region):
self.destination_account = account_id
self.execution_account = execution_account_id
# init common functions class
super().__init__(region, execution_account_id)
self.response = {"provision_products": provision_products, "update_products": update_products, "account": account_id, "status": "progress", "deployed_products":deployed_products, "failed_products": failed_products, "skipped_products": skipped_products, "max_iterations": max_iterations, "iteration": iteration}
# to avoid infinite loop, lambda will stop execution of state machine after define maximum interations
if iteration >= max_iterations:
self._log_error(f'Baseline of new account reach max iterations ({max_iterations})')
self._send_notification('Baseline time out', f'Baseline of new account reach max iterations ({max_iterations})')
self.response['status'] = 'done'
else:
# get list of provision name from products define in configuration
self.iterate = False
self.deployment_products_list = []
self.__get_products_in_scope(provision_products)
self.__get_products_in_scope(update_products)
# set connection to tracking table
self._set_table_connection()
# start deployment process
provision_status = self.__baseline_products(provision_products, 'deploy')
# start update process
update_status = self.__baseline_products(update_products, 'update')
if provision_status == 'done' and update_status == 'done':
self.response['status'] = 'done'
else:
self.response['status'] = 'progress'
# increase iteration if dependency still in progress
if self.iterate:
self.response['iteration'] = iteration + 1