def create()

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


def create(event, _):
    """
    Helper function for resource creation.
    Populates Data with Lex Bot Name so poll_create helper can refer to it.
    Raises Exception if required resource properties are missing.
    Any exception raised is displayed in CloudFormation console.
    :param event: Event body
    :param _: Context (unused)
    :return: None
    """
    logger.info("Got Create")

    if 'ResourceProperties' not in event:
        raise ValueError("Please provide resource properties")
    required_properties = ['LexS3Bucket',
                           'LexFileKey',
                           'FulfillmentLambda',
                           'KendraSearchRole',
                           'KendraIndex',
                           'AccountID']
    for resource_property in required_properties:
        check_required_properties(event['ResourceProperties'], resource_property)

    lex_json = read_json_file_from_s3(event['ResourceProperties']['LexS3Bucket'],
                                      event['ResourceProperties']['LexFileKey'])

    bot_name, bot_version = create_lex_bot(lex_json['resource'],
                              event['ResourceProperties']['FulfillmentLambda'], event['ResourceProperties']['KendraSearchRole'], event['ResourceProperties']['KendraIndex'], event['ResourceProperties']['AccountID'])
    helper.Data['BotName'] = bot_name
    helper.Data['BotVersion'] = bot_version