Skip to content

Commit 2226228

Browse files
authored
feat: support composable index templates (#55)
1 parent 3ab7461 commit 2226228

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ Here is a working example of using this Terraform module:
9494
| [aws_elasticsearch_domain_saml_options.opensearch](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticsearch_domain_saml_options) | resource |
9595
| [aws_iam_service_linked_role.es](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_service_linked_role) | resource |
9696
| [aws_route53_record.opensearch](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource |
97+
| [elasticsearch_composable_index_template.composable_index_template](https://registry.terraform.io/providers/phillbaker/elasticsearch/latest/docs/resources/composable_index_template) | resource |
9798
| [elasticsearch_index.index](https://registry.terraform.io/providers/phillbaker/elasticsearch/latest/docs/resources/index) | resource |
9899
| [elasticsearch_index_template.index_template](https://registry.terraform.io/providers/phillbaker/elasticsearch/latest/docs/resources/index_template) | resource |
99100
| [elasticsearch_opensearch_ism_policy.ism_policy](https://registry.terraform.io/providers/phillbaker/elasticsearch/latest/docs/resources/opensearch_ism_policy) | resource |
@@ -126,6 +127,8 @@ Here is a working example of using this Terraform module:
126127
| <a name="input_cluster_version"></a> [cluster\_version](#input\_cluster\_version) | The version of OpenSearch to deploy. | `string` | `"1.0"` | no |
127128
| <a name="input_cognito_options"></a> [cognito\_options](#input\_cognito\_options) | Configuration block for authenticating Kibana with Cognito. | `map(string)` | `{}` | no |
128129
| <a name="input_cognito_options_enabled"></a> [cognito\_options\_enabled](#input\_cognito\_options\_enabled) | Whether Amazon Cognito authentication with Kibana is enabled or not. | `bool` | `false` | no |
130+
| <a name="input_composable_index_template_files"></a> [composable\_index\_template\_files](#input\_composable\_index\_template\_files) | A set of all composable index template files to create. | `set(string)` | `[]` | no |
131+
| <a name="input_composable_index_templates"></a> [composable\_index\_templates](#input\_composable\_index\_templates) | A map of all composable index templates to create. | `map(any)` | `{}` | no |
129132
| <a name="input_create_service_role"></a> [create\_service\_role](#input\_create\_service\_role) | Indicates whether to create the service-linked role. See https://docs.aws.amazon.com/opensearch-service/latest/developerguide/slr.html | `bool` | `true` | no |
130133
| <a name="input_custom_endpoint"></a> [custom\_endpoint](#input\_custom\_endpoint) | Fully qualified domain for your custom endpoint. If not specified, then it defaults to <cluster\_name>.<cluster\_domain> | `string` | `null` | no |
131134
| <a name="input_custom_endpoint_certificate_arn"></a> [custom\_endpoint\_certificate\_arn](#input\_custom\_endpoint\_certificate\_arn) | The ARN of the custom ACM certificate. | `string` | `""` | no |

composable_index_template.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
resource "elasticsearch_composable_index_template" "composable_index_template" {
2+
for_each = local.composable_index_templates
3+
4+
name = each.key
5+
body = jsonencode(each.value)
6+
7+
depends_on = [
8+
elasticsearch_opensearch_roles_mapping.master_user_arn,
9+
aws_route53_record.opensearch
10+
]
11+
}

locals.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
locals {
2+
composable_index_templates = merge({
3+
for filename in var.composable_index_template_files :
4+
replace(basename(filename), "/\\.(ya?ml|json)$/", "") =>
5+
length(regexall("\\.ya?ml$", filename)) > 0 ? yamldecode(file(filename)) : jsondecode(file(filename))
6+
}, var.composable_index_templates)
7+
28
indices = merge({
39
for filename in var.index_files :
410
replace(basename(filename), "/\\.(ya?ml|json)$/", "") =>

variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,18 @@ variable "saml_master_user_name" {
199199
default = null
200200
}
201201

202+
variable "composable_index_templates" {
203+
description = "A map of all composable index templates to create."
204+
type = map(any)
205+
default = {}
206+
}
207+
208+
variable "composable_index_template_files" {
209+
description = "A set of all composable index template files to create."
210+
type = set(string)
211+
default = []
212+
}
213+
202214
variable "index_templates" {
203215
description = "A map of all index templates to create."
204216
type = map(any)

0 commit comments

Comments
 (0)