This template sets up an AWS Opensearch domain and associates a TXT dictionary package with it.

Terraform Template

resource "aws_opensearch_domain" "my_domain" {

  cluster_config {
    instance_type = "r4.large.search"
  }
  domain_name = "my-opensearch-domain"
  engine_version = "Elasticsearch_7.10"
}

resource "aws_opensearch_package" "example" {
  package_name = "example-txt"

  package_source {
    s3_bucket_name = "aws_s3_bucket.my_opensearch_packages.bucket"
    s3_key = "aws_s3_object.example.key"
  }
  package_type = "TXT-DICTIONARY"
}

resource "aws_opensearch_package_association" "example" {
  domain_name = aws_opensearch_domain.my_domain.domain_name
  package_id = aws_opensearch_package.example.id
}