def create_ou_move_act()

in source/Lambda/innovation_create_account_ou.py [0:0]


def create_ou_move_act(client, root, name, act):

    try:
        logger.info("Moving Account: "+act+" to OU "+name)
        _ou = client.create_organizational_unit(
            Name=name,
            ParentId=root
        )

    except Exception as e:
        message = {'MESSAGE': 'Exception occurred while creating OU','FILE': __file__.split('/')[-1], 
                           'METHOD': inspect.stack()[0][3], 'EXCEPTION': str(e), 'TRACE': traceback.format_exc()}
        logger.exception(message)
        raise

    try:
        parents = client.list_parents(
            ChildId=act
        )

        curr_parent = parents["Parents"][0]["Id"]

        client.move_account(
            AccountId=act,
            SourceParentId=curr_parent,
            DestinationParentId=_ou["OrganizationalUnit"]["Id"]
        )
    except Exception as e:
        message = {'MESSAGE': 'Exception occurred while moving account to OU','FILE': __file__.split('/')[-1], 
                              'METHOD': inspect.stack()[0][3], 'EXCEPTION': str(e), 'TRACE': traceback.format_exc()}
        logger.exception(message)
        raise

    return _ou["OrganizationalUnit"]["Id"]