From 53ad5a2c58c942c5d1c2df50aeeb66ea91e5608a Mon Sep 17 00:00:00 2001 From: abhinavkumarsph Date: Mon, 29 Jul 2024 15:33:58 +0800 Subject: [PATCH] feat: slack channel and monitor submodules --- examples/notification/main.tf | 79 ++++++++++++++++++++++++++++++ examples/notification/providers.tf | 2 + examples/notification/versions.tf | 10 ++++ modules/channel/slack/README.md | 37 ++++++++++++++ modules/channel/slack/main.tf | 16 ++++++ modules/channel/slack/outputs.tf | 4 ++ modules/channel/slack/variables.tf | 20 ++++++++ modules/channel/slack/versions.tf | 10 ++++ modules/monitor/README.md | 34 +++++++++++++ modules/monitor/main.tf | 3 ++ modules/monitor/outputs.tf | 4 ++ modules/monitor/variables.tf | 4 ++ modules/monitor/versions.tf | 10 ++++ 13 files changed, 233 insertions(+) create mode 100644 examples/notification/main.tf create mode 100644 examples/notification/providers.tf create mode 100644 examples/notification/versions.tf create mode 100644 modules/channel/slack/README.md create mode 100644 modules/channel/slack/main.tf create mode 100644 modules/channel/slack/outputs.tf create mode 100644 modules/channel/slack/variables.tf create mode 100644 modules/channel/slack/versions.tf create mode 100644 modules/monitor/README.md create mode 100644 modules/monitor/main.tf create mode 100644 modules/monitor/outputs.tf create mode 100644 modules/monitor/variables.tf create mode 100644 modules/monitor/versions.tf diff --git a/examples/notification/main.tf b/examples/notification/main.tf new file mode 100644 index 0000000..4943dc1 --- /dev/null +++ b/examples/notification/main.tf @@ -0,0 +1,79 @@ +module "slack_channel" { + source = "../../modules/channel/slack" + + id = "test_slack" + name = "Test slack channel" + webhook_url = "https://hooks.slack.com/services/test" +} + +module "monitor" { + source = "../../modules/monitor" + + body = < 0", + "lang" : "painless" + } + }, + "actions" : [ + { + "name" : "Slack", + "destination_id" : "${module.slack_channel.id}", + "message_template" : { + "source" : "bogus", + "lang" : "mustache" + }, + "throttle_enabled" : false, + "subject_template" : { + "source" : "Production Errors", + "lang" : "mustache" + } + } + ] + } + ] +} +EOF +} diff --git a/examples/notification/providers.tf b/examples/notification/providers.tf new file mode 100644 index 0000000..6917ade --- /dev/null +++ b/examples/notification/providers.tf @@ -0,0 +1,2 @@ +provider "opensearch" { +} diff --git a/examples/notification/versions.tf b/examples/notification/versions.tf new file mode 100644 index 0000000..05d3e38 --- /dev/null +++ b/examples/notification/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.4" + + required_providers { + opensearch = { + source = "opensearch-project/opensearch" + version = "~> 2.3.0" + } + } +} diff --git a/modules/channel/slack/README.md b/modules/channel/slack/README.md new file mode 100644 index 0000000..5f245bd --- /dev/null +++ b/modules/channel/slack/README.md @@ -0,0 +1,37 @@ +## Requirements + +| Name | Version | +|------|---------| +| [terraform](#requirement\_terraform) | >= 1.4 | +| [opensearch](#requirement\_opensearch) | >= 2.0 | + +## Providers + +| Name | Version | +|------|---------| +| [opensearch](#provider\_opensearch) | >= 2.0 | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [opensearch_channel_configuration.this](https://registry.terraform.io/providers/opensearch-project/opensearch/latest/docs/resources/channel_configuration) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [description](#input\_description) | Channel config description | `string` | `""` | no | +| [id](#input\_id) | Channel config ID | `string` | n/a | yes | +| [name](#input\_name) | Channel config name | `string` | n/a | yes | +| [webhook\_url](#input\_webhook\_url) | Slack webhook URL | `string` | n/a | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| [id](#output\_id) | The ID of the channel configuration | diff --git a/modules/channel/slack/main.tf b/modules/channel/slack/main.tf new file mode 100644 index 0000000..93c89d7 --- /dev/null +++ b/modules/channel/slack/main.tf @@ -0,0 +1,16 @@ +resource "opensearch_channel_configuration" "this" { + body = < [terraform](#requirement\_terraform) | >= 1.4 | +| [opensearch](#requirement\_opensearch) | >= 2.0 | + +## Providers + +| Name | Version | +|------|---------| +| [opensearch](#provider\_opensearch) | >= 2.0 | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [opensearch_monitor.this](https://registry.terraform.io/providers/opensearch-project/opensearch/latest/docs/resources/monitor) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [body](#input\_body) | The monitor document | `string` | n/a | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| [id](#output\_id) | The ID of the monitor | diff --git a/modules/monitor/main.tf b/modules/monitor/main.tf new file mode 100644 index 0000000..f97cd5c --- /dev/null +++ b/modules/monitor/main.tf @@ -0,0 +1,3 @@ +resource "opensearch_monitor" "this" { + body = var.body +} diff --git a/modules/monitor/outputs.tf b/modules/monitor/outputs.tf new file mode 100644 index 0000000..9dd5d0d --- /dev/null +++ b/modules/monitor/outputs.tf @@ -0,0 +1,4 @@ +output "id" { + description = "The ID of the monitor" + value = opensearch_monitor.this.id +} diff --git a/modules/monitor/variables.tf b/modules/monitor/variables.tf new file mode 100644 index 0000000..eee1e39 --- /dev/null +++ b/modules/monitor/variables.tf @@ -0,0 +1,4 @@ +variable "body" { + description = "The monitor document" + type = string +} diff --git a/modules/monitor/versions.tf b/modules/monitor/versions.tf new file mode 100644 index 0000000..c1a9caf --- /dev/null +++ b/modules/monitor/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.4" + + required_providers { + opensearch = { + source = "opensearch-project/opensearch" + version = ">= 2.0" + } + } +}