diff --git a/modules/dashboard/index-pattern/README.md b/modules/dashboard/index-pattern/README.md new file mode 100644 index 0000000..43e3165 --- /dev/null +++ b/modules/dashboard/index-pattern/README.md @@ -0,0 +1,36 @@ +## Requirements + +| Name | Version | +|------|---------| +| [terraform](#requirement\_terraform) | >= 1.4 | +| [opensearch](#requirement\_opensearch) | >= 1.0 | + +## Providers + +| Name | Version | +|------|---------| +| [opensearch](#provider\_opensearch) | >= 1.0 | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [opensearch_dashboard_object.index_pattern](https://registry.terraform.io/providers/opensearch-project/opensearch/latest/docs/resources/dashboard_object) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [pattern](#input\_pattern) | The index pattern | `string` | n/a | yes | +| [pattern\_id](#input\_pattern\_id) | The ID of index pattern | `string` | `null` | no | +| [time\_field\_name](#input\_time\_field\_name) | Field name which has the timestamp | `string` | n/a | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| [id](#output\_id) | The ID of the index pattern | diff --git a/modules/dashboard/index-pattern/main.tf b/modules/dashboard/index-pattern/main.tf new file mode 100644 index 0000000..5fa235d --- /dev/null +++ b/modules/dashboard/index-pattern/main.tf @@ -0,0 +1,21 @@ +locals { + id = coalesce(var.pattern_id, split("-*", var.pattern)[0]) +} + +resource "opensearch_dashboard_object" "index_pattern" { + body = <