Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: index pattern submodule #31

Merged
merged 2 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions modules/dashboard/index-pattern/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.4 |
| <a name="requirement_opensearch"></a> [opensearch](#requirement\_opensearch) | >= 1.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_opensearch"></a> [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 |
|------|-------------|------|---------|:--------:|
| <a name="input_pattern"></a> [pattern](#input\_pattern) | The index pattern | `string` | n/a | yes |
| <a name="input_pattern_id"></a> [pattern\_id](#input\_pattern\_id) | The ID of index pattern | `string` | `null` | no |
| <a name="input_time_field_name"></a> [time\_field\_name](#input\_time\_field\_name) | Field name which has the timestamp | `string` | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_id"></a> [id](#output\_id) | The ID of the index pattern |
21 changes: 21 additions & 0 deletions modules/dashboard/index-pattern/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
locals {
id = coalesce(var.pattern_id, split("-*", var.pattern)[0])
}

resource "opensearch_dashboard_object" "index_pattern" {
body = <<EOF
[
{
"_id": "index-pattern:${local.id}",
"_type": "doc",
"_source": {
"type": "index-pattern",
"index-pattern": {
"title": "${var.pattern}",
"timeFieldName": "${var.time_field_name}"
}
}
}
]
EOF
}
4 changes: 4 additions & 0 deletions modules/dashboard/index-pattern/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "id" {
description = "The ID of the index pattern"
value = opensearch_dashboard_object.index_pattern.id
}
15 changes: 15 additions & 0 deletions modules/dashboard/index-pattern/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
variable "pattern" {
description = "The index pattern"
type = string
}

variable "pattern_id" {
description = "The ID of index pattern"
type = string
default = null
}

variable "time_field_name" {
description = "Field name which has the timestamp"
type = string
}
10 changes: 10 additions & 0 deletions modules/dashboard/index-pattern/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_version = ">= 1.4"

required_providers {
opensearch = {
source = "opensearch-project/opensearch"
version = ">= 1.0"
}
}
}
Loading