in customizations/AccountFactory/EnrollAccount/enroll_account.py [0:0]
def get_parent_for_account(account_id):
'''Return the OU id of an account'''
parent = None
role_message = 'Use -c|--create_role option to deploy stacks on Root Level'
try:
parent = ORG.list_parents(ChildId=account_id)['Parents']
except ClientError as exe:
raise exe
if parent:
if parent[0]['Type'] == 'ROOT':
if ROOT_LEVEL:
result = parent[0]['Id']
else:
error_and_exit('Account is part of Root.' + role_message)
elif parent[0]['Type'] == 'ORGANIZATIONAL_UNIT':
result = parent[0]['Id']
else:
error_and_exit('Unknown status: {}'.format(parent))
return result