Resource: aws_kendra_data_source

Terraform resource for managing an AWS Kendra Data Source.

Example Usage

Basic Usage

resource "aws_kendra_data_source" "example" {
  index_id      = aws_kendra_index.example.id
  name          = "example"
  description   = "example"
  language_code = "en"
  type          = "CUSTOM"

  tags = {
    "hello" = "world"
  }
}

S3 Connector

With Schedule

resource "aws_kendra_data_source" "example" {
  index_id = aws_kendra_index.example.id
  name     = "example"
  type     = "S3"
  role_arn = aws_iam_role.example.arn
  schedule = "cron(9 10 1 * ? *)"

  configuration {
    s3_configuration {
      bucket_name = aws_s3_bucket.example.id
    }
  }
}

With Access Control List

resource "aws_kendra_data_source" "example" {
  index_id = aws_kendra_index.example.id
  name     = "example"
  type     = "S3"
  role_arn = aws_iam_role.example.arn

  configuration {
    s3_configuration {
      bucket_name = aws_s3_bucket.example.id

      access_control_list_configuration {
        key_path = "s3://${aws_s3_bucket.example.id}/path-1"
      }
    }
  }
}

With Documents Metadata Configuration

resource "aws_kendra_data_source" "example" {
  index_id = aws_kendra_index.example.id
  name     = "example"
  type     = "S3"
  role_arn = aws_iam_role.example.arn

  configuration {
    s3_configuration {
      bucket_name        = aws_s3_bucket.example.id
      exclusion_patterns = ["example"]
      inclusion_patterns = ["hello"]
      inclusion_prefixes = ["world"]

      documents_metadata_configuration {
        s3_prefix = "example"
      }
    }
  }
}

Web Crawler Connector

With Seed URLs

resource "aws_kendra_data_source" "example" {
  index_id = aws_kendra_index.example.id
  name     = "example"
  type     = "WEBCRAWLER"
  role_arn = aws_iam_role.example.arn

  configuration {
    web_crawler_configuration {
      urls {
        seed_url_configuration {
          seed_urls = [
            "REPLACE_WITH_YOUR_URL"
          ]
        }
      }
    }
  }
}

With Site Maps

resource "aws_kendra_data_source" "example" {
  index_id = aws_kendra_index.example.id
  name     = "example"
  type     = "WEBCRAWLER"
  role_arn = aws_iam_role.example.arn

  configuration {
    web_crawler_configuration {
      urls {
        site_maps_configuration {
          site_maps = [
            "REPLACE_WITH_YOUR_URL"
          ]
        }
      }
    }
  }
}

With Web Crawler Mode

resource "aws_kendra_data_source" "example" {
  index_id = aws_kendra_index.example.id
  name     = "example"
  type     = "WEBCRAWLER"
  role_arn = aws_iam_role.example.arn

  configuration {
    web_crawler_configuration {
      urls {
        seed_url_configuration {
          web_crawler_mode = "SUBDOMAINS"

          seed_urls = [
            "REPLACE_WITH_YOUR_URL"
          ]
        }
      }
    }
  }
}

With Authentication Configuration

resource "aws_kendra_data_source" "example" {
  depends_on = [
    aws_secretsmanager_secret_version.example
  ]

  index_id = aws_kendra_index.example.id
  name     = "example"
  type     = "WEBCRAWLER"
  role_arn = aws_iam_role.example.arn

  configuration {
    web_crawler_configuration {
      authentication_configuration {
        basic_authentication {
          credentials = aws_secretsmanager_secret.example.arn
          host        = "a.example.com"
          port        = "443"
        }
      }

      urls {
        seed_url_configuration {
          seed_urls = [
            "REPLACE_WITH_YOUR_URL"
          ]
        }
      }
    }
  }
}

With Crawl Depth

resource "aws_kendra_data_source" "example" {
  index_id = aws_kendra_index.example.id
  name     = "example"
  type     = "WEBCRAWLER"
  role_arn = aws_iam_role.example.arn

  configuration {
    web_crawler_configuration {
      crawl_depth = 3

      urls {
        seed_url_configuration {
          seed_urls = [
            "REPLACE_WITH_YOUR_URL"
          ]
        }
      }
    }
  }
}
resource "aws_kendra_data_source" "example" {
  index_id = aws_kendra_index.example.id
  name     = "example"
  type     = "WEBCRAWLER"
  role_arn = aws_iam_role.example.arn

  configuration {
    web_crawler_configuration {
      max_links_per_page = 100

      urls {
        seed_url_configuration {
          seed_urls = [
            "REPLACE_WITH_YOUR_URL"
          ]
        }
      }
    }
  }
}

With Max Urls Per Minute Crawl Rate

resource "aws_kendra_data_source" "example" {
  index_id = aws_kendra_index.example.id
  name     = "example"
  type     = "WEBCRAWLER"
  role_arn = aws_iam_role.example.arn

  configuration {
    web_crawler_configuration {
      max_urls_per_minute_crawl_rate = 300

      urls {
        seed_url_configuration {
          seed_urls = [
            "REPLACE_WITH_YOUR_URL"
          ]
        }
      }
    }
  }
}

With Proxy Configuration

resource "aws_kendra_data_source" "example" {
  depends_on = [
    aws_secretsmanager_secret_version.example
  ]

  index_id = aws_kendra_index.example.id
  name     = "example"
  type     = "WEBCRAWLER"
  role_arn = aws_iam_role.example.arn

  configuration {
    web_crawler_configuration {
      proxy_configuration {
        credentials = aws_secretsmanager_secret.example.arn
        host        = "a.example.com"
        port        = "443"
      }

      urls {
        seed_url_configuration {
          seed_urls = [
            "REPLACE_WITH_YOUR_URL"
          ]
        }
      }
    }
  }
}

With URL Exclusion and Inclusion Patterns

resource "aws_kendra_data_source" "example" {
  index_id = aws_kendra_index.example.id
  name     = "example"
  type     = "WEBCRAWLER"
  role_arn = aws_iam_role.example.arn

  configuration {
    web_crawler_configuration {
      url_exclusion_patterns = ["example"]
      url_inclusion_patterns = ["hello"]

      urls {
        seed_url_configuration {
          seed_urls = [
            "REPLACE_WITH_YOUR_URL"
          ]
        }
      }
    }
  }
}

Argument Reference

The following arguments are required:

The following arguments are optional:

configuration Block

The configuration configuration block supports the following arguments:

s3_configuration Block

The s3_configuration configuration block supports the following arguments:

access_control_list_configuration Block

The access_control_list_configuration configuration block supports the following arguments:

documents_metadata_configuration Block

The documents_metadata_configuration configuration block supports the following arguments:

web_crawler_configuration Block

The web_crawler_configuration configuration block supports the following arguments:

authentication_configuration Block

The authentication_configuration configuration block supports the following arguments:

basic_authentication Block

The basic_authentication configuration block supports the following arguments:

proxy_configuration Block

The proxy_configuration configuration block supports the following arguments:

urls Block

The urls configuration block supports the following arguments:

seed_url_configuration Block

The seed_url_configuration configuration block supports the following arguments:

site_maps_configuration Block

The site_maps_configuration configuration block supports the following arguments:

custom_document_enrichment_configuration Block

The custom_document_enrichment_configuration configuration block supports the following arguments:

inline_configurations Block

The inline_configurations configuration block supports the following arguments:

condition Block

The condition configuration blocks supports the following arguments:

target Block

The target configuration block supports the following arguments:

target_document_attribute_value Block

The target_document_attribute_value configuration blocks supports the following arguments:

pre_extraction_hook_configuration and post_extraction_hook_configuration Blocks

The pre_extraction_hook_configuration and post_extraction_hook_configuration configuration blocks each supports the following arguments:

invocation_condition Block

The invocation_condition configuration blocks supports the following arguments:

condition_on_value Block

The condition_on_value configuration blocks supports the following arguments:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Timeouts

Configuration options:

Import

In Terraform v1.5.0 and later, use an import block to import Kendra Data Source using the unique identifiers of the data_source and index separated by a slash (/). For example:

import {
  to = aws_kendra_data_source.example
  id = "1045d08d-66ef-4882-b3ed-dfb7df183e90/b34dfdf7-1f2b-4704-9581-79e00296845f"
}

Using terraform import, import Kendra Data Source using the unique identifiers of the data_source and index separated by a slash (/). For example:

% terraform import aws_kendra_data_source.example 1045d08d-66ef-4882-b3ed-dfb7df183e90/b34dfdf7-1f2b-4704-9581-79e00296845f