def check_kendra_index_status()

in functions/source/kendra_custom_resource/kendra_custom_resource.py [0:0]


def check_kendra_index_status(kendra_index_id):
    """
    Checks status of kendra index.
    Raises an exception if Kendra Index is in an unexpected state.
    :param kendra_index_id: Kendra Index Id
    :return: True if index is Active, False otherwise
    """
    response = kendra_client.describe_index(Id=kendra_index_id)
    status = response['Status']
    logger.info(status)
    if status == 'DELETING':
        raise Exception("Kendra Index is in DELETING state")
    if status == 'FAILED':
        raise Exception("Kendra Index is in FAILED state with Error Message: "
                        + response['ErrorMessage'])
    return status == 'ACTIVE'