in customizations/AccountFactory/EnrollAccount/enroll_account.py [0:0]
def start_enrolling_accounts(data):
'''Enroll accounts from the dataset sequentially'''
# Get list of Service Catalog provisioned products in
# AVAILABLE / ERROR state
(acct_map, error_list, transit_list) = get_provisioned_product_list()
# Get the Product Id of the AWS Control Tower Account Factory
prod_id = get_product_id()
# Get the Provisioning Artifact Id of the AWS Control Tower Account Factory
pa_id = get_provisioning_artifact_id(prod_id)
if len(transit_list) > 0:
error_and_exit('Update in progress. Allow UNDER_CHANGE or ' +
'PLAN_IN_PROGRESS provisioned products ' +
'to complete:' + str(transit_list))
else:
for account_id in data:
pp_status = 'UNDER_CHANGE'
sleep_time = 360
role_exists = check_and_create_role(account_id)
if role_exists:
pp_name = generate_provisioned_product_name(data[account_id])
p_status = provision_sc_product(prod_id, pa_id, pp_name,
data[account_id])
if not p_status:
pp_status = 'ERROR'
# Wait until the Service Catalog Product Provisioning Completes
while pp_status == 'UNDER_CHANGE':
LOGGER.info('Status: %s. Waiting for %s min to recheck',
pp_status, sleep_time/60)
sleep(sleep_time)
if sleep_time > 60:
sleep_time -= 60
pp_status = get_provisioned_product_status(pp_name)
if pp_status == 'AVAILABLE':
LOGGER.info('SUCCESS: %s updated', account_id)
else:
LOGGER.error('%s: %s', pp_status, account_id)
else:
LOGGER.error('Unable to create role for %s', account_id)