diff --git a/README.md b/README.md index 537a4e0..e9fe487 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ data "http" "saml_metadata" { url = local.saml_metadata_url } -provider "elasticsearch" { +provider "opensearch" { url = module.opensearch.cluster_endpoint aws_region = data.aws_region.current.name healthcheck = false @@ -54,10 +54,39 @@ module "opensearch" { saml_metadata_content = data.http.saml_metadata.body indices = { - example-index = { + example-index-1 = { number_of_shards = 2 number_of_replicas = 1 } + example-index-2 = { + number_of_shards = 2 + number_of_replicas = 1 + mappings = { + "properties" : { + "id" : { + "type" : "text" + }, + "name" : { + "type" : "text" + }, + "containerType" : { + "type" : "text" + }, + "containerIds" : { + "type" : "text" + }, + "synonyms" : { + "type" : "text" + }, + "parentEvents" : { + "type" : "text" + }, + "valueType" : { + "type" : "text" + } + } + } + } } } ``` @@ -74,7 +103,7 @@ Here is a working example of using this Terraform module: | Name | Version | |------|---------| -| [terraform](#requirement\_terraform) | >= 1.0.0 | +| [terraform](#requirement\_terraform) | >= 1.3.0 | | [aws](#requirement\_aws) | >= 4.12.0 | | [opensearch](#requirement\_opensearch) | >= 2.0.0 | @@ -144,7 +173,7 @@ Here is a working example of using this Terraform module: | [index\_files](#input\_index\_files) | A set of all index files to create. | `set(string)` | `[]` | no | | [index\_template\_files](#input\_index\_template\_files) | A set of all index template files to create. | `set(string)` | `[]` | no | | [index\_templates](#input\_index\_templates) | A map of all index templates to create. | `map(any)` | `{}` | no | -| [indices](#input\_indices) | A map of all indices to create. | `map(any)` | `{}` | no | +| [indices](#input\_indices) | A map of all indices to create. |
map(object({
number_of_shards = optional(number)
number_of_replicas = optional(number)
refresh_interval = optional(string)
mappings = optional(any, {})
aliases = optional(any, {})
analysis_analyzer = optional(string)
analysis_char_filter = optional(string)
analysis_filter = optional(string)
analysis_normalizer = optional(string)
analysis_tokenizer = optional(string)
analyze_max_token_count = optional(string)
auto_expand_replicas = optional(string)
blocks_metadata = optional(bool)
blocks_read = optional(bool)
blocks_read_only = optional(bool)
blocks_read_only_allow_delete = optional(bool)
blocks_write = optional(bool)
codec = optional(string)
default_pipeline = optional(string)
gc_deletes = optional(string)
highlight_max_analyzed_offset = optional(string)
include_type_name = optional(string)
index_similarity_default = optional(string)
indexing_slowlog_level = optional(string)
indexing_slowlog_source = optional(string)
indexing_slowlog_threshold_index_debug = optional(string)
indexing_slowlog_threshold_index_info = optional(string)
indexing_slowlog_threshold_index_trace = optional(string)
indexing_slowlog_threshold_index_warn = optional(string)
load_fixed_bitset_filters_eagerly = optional(bool)
max_docvalue_fields_search = optional(string)
max_inner_result_window = optional(string)
max_ngram_diff = optional(string)
max_refresh_listeners = optional(string)
max_regex_length = optional(string)
max_rescore_window = optional(string)
max_result_window = optional(string)
max_script_fields = optional(string)
max_shingle_diff = optional(string)
max_terms_count = optional(string)
number_of_routing_shards = optional(string)
rollover_alias = optional(string)
routing_allocation_enable = optional(string)
routing_partition_size = optional(string)
routing_rebalance_enable = optional(string)
search_idle_after = optional(string)
search_slowlog_level = optional(string)
search_slowlog_threshold_fetch_info = optional(string)
search_slowlog_threshold_fetch_debug = optional(string)
search_slowlog_threshold_fetch_trace = optional(string)
search_slowlog_threshold_fetch_warn = optional(string)
search_slowlog_threshold_query_debug = optional(string)
search_slowlog_threshold_query_info = optional(string)
search_slowlog_threshold_query_trace = optional(string)
search_slowlog_threshold_query_warn = optional(string)
shard_check_on_startup = optional(string)
sort_field = optional(string)
sort_order = optional(string)
}))
| `{}` | no | | [ism\_policies](#input\_ism\_policies) | A map of all ISM policies to create. | `map(any)` | `{}` | no | | [ism\_policy\_files](#input\_ism\_policy\_files) | A set of all ISM policy files to create. | `set(string)` | `[]` | no | | [log\_streams\_enabled](#input\_log\_streams\_enabled) | Configuration for which log streams to enable sending logs to CloudWatch. | `map(string)` |
{
"AUDIT_LOGS": "false",
"ES_APPLICATION_LOGS": "false",
"INDEX_SLOW_LOGS": "false",
"SEARCH_SLOW_LOGS": "false"
}
| no | diff --git a/index.tf b/index.tf index add6c54..1ff2524 100644 --- a/index.tf +++ b/index.tf @@ -1,13 +1,66 @@ resource "opensearch_index" "index" { for_each = local.indices - name = each.key - number_of_shards = try(each.value.number_of_shards, "") - number_of_replicas = try(each.value.number_of_replicas, "") - refresh_interval = try(each.value.refresh_interval, "") - mappings = jsonencode(try(each.value.mappings, {})) - aliases = jsonencode(try(each.value.aliases, {})) - force_destroy = true + name = each.key + number_of_shards = try(each.value.number_of_shards, "") + number_of_replicas = try(each.value.number_of_replicas, "") + refresh_interval = try(each.value.refresh_interval, "") + mappings = jsonencode(try(each.value.mappings, {})) + aliases = jsonencode(try(each.value.aliases, {})) + analysis_analyzer = try(each.value.analysis_analyzer, null) + analysis_char_filter = try(each.value.analysis_char_filter, null) + analysis_filter = try(each.value.analysis_filter, null) + analysis_normalizer = try(each.value.analysis_normalizer, null) + analysis_tokenizer = try(each.value.analysis_tokenizer, null) + analyze_max_token_count = try(each.value.analyze_max_token_count, null) + auto_expand_replicas = try(each.value.auto_expand_replicas, null) + blocks_metadata = try(each.value.blocks_metadata, null) + blocks_read = try(each.value.blocks_read, null) + blocks_read_only = try(each.value.blocks_read_only, null) + blocks_read_only_allow_delete = try(each.value.blocks_read_only_allow_delete, null) + blocks_write = try(each.value.blocks_write, null) + codec = try(each.value.codec, null) + default_pipeline = try(each.value.default_pipeline, null) + gc_deletes = try(each.value.gc_deletes, null) + highlight_max_analyzed_offset = try(each.value.highlight_max_analyzed_offset, null) + include_type_name = try(each.value.include_type_name, null) + index_similarity_default = try(each.value.index_similarity_default, null) + indexing_slowlog_level = try(each.value.indexing_slowlog_level, null) + indexing_slowlog_source = try(each.value.indexing_slowlog_source, null) + indexing_slowlog_threshold_index_debug = try(each.value.indexing_slowlog_threshold_index_debug, null) + indexing_slowlog_threshold_index_info = try(each.value.indexing_slowlog_threshold_index_info, null) + indexing_slowlog_threshold_index_trace = try(each.value.indexing_slowlog_threshold_index_trace, null) + indexing_slowlog_threshold_index_warn = try(each.value.indexing_slowlog_threshold_index_warn, null) + load_fixed_bitset_filters_eagerly = try(each.value.load_fixed_bitset_filters_eagerly, null) + max_docvalue_fields_search = try(each.value.max_docvalue_fields_search, null) + max_inner_result_window = try(each.value.max_inner_result_window, null) + max_ngram_diff = try(each.value.max_ngram_diff, null) + max_refresh_listeners = try(each.value.max_refresh_listeners, null) + max_regex_length = try(each.value.max_regex_length, null) + max_rescore_window = try(each.value.max_rescore_window, null) + max_result_window = try(each.value.max_result_window, null) + max_script_fields = try(each.value.max_script_fields, null) + max_shingle_diff = try(each.value.max_shingle_diff, null) + max_terms_count = try(each.value.max_terms_count, null) + number_of_routing_shards = try(each.value.number_of_routing_shards, null) + rollover_alias = try(each.value.rollover_alias, null) + routing_allocation_enable = try(each.value.routing_allocation_enable, null) + routing_partition_size = try(each.value.routing_partition_size, null) + routing_rebalance_enable = try(each.value.routing_rebalance_enable, null) + search_idle_after = try(each.value.search_idle_after, null) + search_slowlog_level = try(each.value.search_slowlog_level, null) + search_slowlog_threshold_fetch_debug = try(each.value.search_slowlog_threshold_fetch_debug, null) + search_slowlog_threshold_fetch_info = try(each.value.search_slowlog_threshold_fetch_info, null) + search_slowlog_threshold_fetch_trace = try(each.value.search_slowlog_threshold_fetch_trace, null) + search_slowlog_threshold_fetch_warn = try(each.value.search_slowlog_threshold_fetch_warn, null) + search_slowlog_threshold_query_debug = try(each.value.search_slowlog_threshold_query_debug, null) + search_slowlog_threshold_query_info = try(each.value.search_slowlog_threshold_query_info, null) + search_slowlog_threshold_query_trace = try(each.value.search_slowlog_threshold_query_trace, null) + search_slowlog_threshold_query_warn = try(each.value.search_slowlog_threshold_query_warn, null) + shard_check_on_startup = try(each.value.shard_check_on_startup, null) + sort_field = try(each.value.sort_field, null) + sort_order = try(each.value.sort_order, null) + force_destroy = true depends_on = [ opensearch_index_template.index_template, diff --git a/variables.tf b/variables.tf index 6a9f61f..5868764 100644 --- a/variables.tf +++ b/variables.tf @@ -237,8 +237,67 @@ variable "ism_policy_files" { variable "indices" { description = "A map of all indices to create." - type = map(any) - default = {} + type = map(object({ + number_of_shards = optional(number) + number_of_replicas = optional(number) + refresh_interval = optional(string) + mappings = optional(any, {}) + aliases = optional(any, {}) + analysis_analyzer = optional(string) + analysis_char_filter = optional(string) + analysis_filter = optional(string) + analysis_normalizer = optional(string) + analysis_tokenizer = optional(string) + analyze_max_token_count = optional(string) + auto_expand_replicas = optional(string) + blocks_metadata = optional(bool) + blocks_read = optional(bool) + blocks_read_only = optional(bool) + blocks_read_only_allow_delete = optional(bool) + blocks_write = optional(bool) + codec = optional(string) + default_pipeline = optional(string) + gc_deletes = optional(string) + highlight_max_analyzed_offset = optional(string) + include_type_name = optional(string) + index_similarity_default = optional(string) + indexing_slowlog_level = optional(string) + indexing_slowlog_source = optional(string) + indexing_slowlog_threshold_index_debug = optional(string) + indexing_slowlog_threshold_index_info = optional(string) + indexing_slowlog_threshold_index_trace = optional(string) + indexing_slowlog_threshold_index_warn = optional(string) + load_fixed_bitset_filters_eagerly = optional(bool) + max_docvalue_fields_search = optional(string) + max_inner_result_window = optional(string) + max_ngram_diff = optional(string) + max_refresh_listeners = optional(string) + max_regex_length = optional(string) + max_rescore_window = optional(string) + max_result_window = optional(string) + max_script_fields = optional(string) + max_shingle_diff = optional(string) + max_terms_count = optional(string) + number_of_routing_shards = optional(string) + rollover_alias = optional(string) + routing_allocation_enable = optional(string) + routing_partition_size = optional(string) + routing_rebalance_enable = optional(string) + search_idle_after = optional(string) + search_slowlog_level = optional(string) + search_slowlog_threshold_fetch_info = optional(string) + search_slowlog_threshold_fetch_debug = optional(string) + search_slowlog_threshold_fetch_trace = optional(string) + search_slowlog_threshold_fetch_warn = optional(string) + search_slowlog_threshold_query_debug = optional(string) + search_slowlog_threshold_query_info = optional(string) + search_slowlog_threshold_query_trace = optional(string) + search_slowlog_threshold_query_warn = optional(string) + shard_check_on_startup = optional(string) + sort_field = optional(string) + sort_order = optional(string) + })) + default = {} } variable "index_files" { diff --git a/versions.tf b/versions.tf index c1efea9..3ec7f84 100644 --- a/versions.tf +++ b/versions.tf @@ -1,5 +1,5 @@ terraform { - required_version = ">= 1.0.0" + required_version = ">= 1.3.0" required_providers { aws = {