def create_kendra_index()

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


def create_kendra_index(resource_properties):
    """
    Creates Kendra Index
    :param resource_properties: Dictionary of resources properties.
                                IndexName, Edition and IndexRoleArn are mandatory.
    :return: Kendra Index Id
    """
    kwargs = {
        'Name': resource_properties['IndexName'],
        'Edition': resource_properties['Edition'],
        'RoleArn': resource_properties['IndexRoleArn']
    }
    if 'IndexDescription' in resource_properties:
        kwargs['Description'] = resource_properties['IndexDescription']
    else:
        kwargs['Description'] = "Kendra Index for Chat bot created using Lex"
    response_kendra = kendra_client.create_index(**kwargs)
    logger.info('IndexID: %s', str(response_kendra['Id']))
    return response_kendra['Id']