Back to Aws Doc Sdk Examples

Amazon Kendra code examples for the SDK for Kotlin

kotlin/services/kendra/README.md

latest4.8 KB
Original Source

Amazon Kendra code examples for the SDK for Kotlin

Overview

This README discusses how to run and test the AWS SDK for Kotlin code examples.

Amazon Kendra is an intelligent search service powered by machine learning (ML).

⚠️ Important

  • The AWS SDK for Kotlin examples perform AWS operations for the account and AWS Region for which you've specified credentials. Running these examples might incur charges on your account. For details about the charges you can expect for a given service and API operation, see AWS Pricing page.
  • Running the tests might result in charges to your AWS account.
  • We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see Grant least privilege.
  • This code is not tested in every AWS Region. For more information, see AWS Regional Services.

Code examples

Single action

The following examples use the KendraClient object:

Scenario

Running the examples

To run these examples, set up your development environment to use Gradle. For more information, see Setting up the AWS SDK for Kotlin.

Some of these examples perform destructive operations on AWS resources, such as deleting an index. Be very careful when running an operation that deletes or modifies AWS resources in your account.

Tests

⚠️ Running the tests might result in charges to your AWS account.

You can test the Kotlin code examples for Amazon Kendra by running a test file named KendraTest. This file uses JUnit 5 to run the JUnit tests and is located in the src/test/java folder. For more information, see https://junit.org/junit5/.

You can run the JUnit tests from an IDE, such as IntelliJ, or from the command line by using Maven. As each test is run, you can view messages that inform you if the various tests succeed or fail. For example, the following message informs you that Test 3 passed.

Test 3 passed

WARNING: _Running these JUnit tests manipulates real AWS resources and might incur charges on your account.

Properties file

Before running the Amazon DynamoDB JUnit tests, you must define values in the config.properties file located in the resources folder. This file contains values that are required to run the JUnit tests. For example, you define an index name used for various tests. If you do not define all values, the JUnit tests fail.

Define these values to successfully run the JUnit tests:

  • indexName - The name for the new index.
  • dataSourceName - The name for the new data source.
  • indexDescription - The description for the index.
  • indexRoleArn – An AWS Identity and Access Management (IAM) role that gives Amazon Kendra permissions to access your Amazon CloudWatch logs and metrics.
  • s3BucketName - An Amazon S3 bucket name used as your data source.
  • dataSourceDescription – A description for the data source.
  • text – The text used to perform a query operation.
  • dataSourceRoleArn – The Amazon Resource Name (ARN) of an IAM role with permission to access the data source.

Additional resources

Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0