def get_account_id_from_session(session):
    """
    gets the account id from the session using the iam client.  This method will work even
    if you have assumed a role in another account.
    Args:
        session (Session): Boto3 session used to lookup information in AWS.
    Returns:
        (str) AWS account id
    """

    if session is None:
        return None

    return session.client('iam').list_users(MaxItems=1)["Users"][0]["Arn"].split(':')[4]