From 0987982e9e000853248686b9faefe2b25737457a Mon Sep 17 00:00:00 2001
From: Anisimova Karina <51861302+Karina5005@users.noreply.github.com>
Date: Wed, 8 Nov 2023 11:04:39 +0300
Subject: [PATCH] feat: Add module message template (#4)
---
README.md | 41 ++++++++++++++++++++++++++++++++++++++++-
main.tf | 14 ++++++++++++++
variables.tf | 45 +++++++++++++++++++++++++++++++++++++++++++++
versions.tf | 7 +++++++
4 files changed, 106 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 7234d11..29b0f4a 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,40 @@
-# Module name
\ No newline at end of file
+# Huawei Cloud LTS Message Template
+
+## Requirements
+
+| Name | Version |
+|------|---------|
+| [terraform](#requirement\_terraform) | ~> 1.4 |
+| [huaweicloud](#requirement\_huaweicloud) | ~>1.47 |
+
+## Providers
+
+| Name | Version |
+|------|---------|
+| [huaweicloud](#provider\_huaweicloud) | ~>1.47 |
+
+## Modules
+
+No modules.
+
+## Resources
+
+| Name | Type |
+|------|------|
+| [huaweicloud_lts_notification_template.test](https://registry.terraform.io/providers/huaweicloud/huaweicloud/latest/docs/resources/lts_notification_template) | resource |
+
+## Inputs
+
+| Name | Description | Type | Default | Required |
+|------|-------------|------|---------|:--------:|
+| [content](#input\_content) | Content of template | `string` | n/a | yes |
+| [locale](#input\_locale) | Language | `string` | `"en-us"` | no |
+| [name](#input\_name) | Specifies the name of the template | `string` | n/a | yes |
+| [name\_postfix](#input\_name\_postfix) | Name Postfix | `string` | `null` | no |
+| [sub\_type](#input\_sub\_type) | Type of the template | `string` | `"email"` | no |
+| [template\_source](#input\_template\_source) | The source of the notification template, currently, this parameter is mandatory to LTS | `string` | `"LTS"` | no |
+
+## Outputs
+
+No outputs.
+
\ No newline at end of file
diff --git a/main.tf b/main.tf
index e69de29..272172f 100644
--- a/main.tf
+++ b/main.tf
@@ -0,0 +1,14 @@
+locals {
+ name = var.name_postfix == null ? var.name : format("%s-%s", var.name, var.name_postfix)
+}
+
+resource "huaweicloud_lts_notification_template" "test" {
+ name = var.name
+ source = var.template_source
+ locale = var.locale
+
+ templates {
+ sub_type = var.sub_type
+ content = var.content
+ }
+}
\ No newline at end of file
diff --git a/variables.tf b/variables.tf
index e69de29..23b7742 100644
--- a/variables.tf
+++ b/variables.tf
@@ -0,0 +1,45 @@
+variable "name" {
+ description = "Specifies the name of the template"
+ type = string
+}
+
+variable "name_postfix" {
+ description = "Name Postfix"
+ type = string
+ default = null
+}
+
+variable "content" {
+ description = "Content of template"
+ type = string
+}
+
+variable "locale" {
+ description = "Language"
+ type = string
+ default = "en-us"
+ validation {
+ condition = contains(["zh-cn", "en-us"], var.locale)
+ error_message = "Locale is not one of: zh-cn, en-us"
+ }
+}
+
+variable "sub_type" {
+ description = "Type of the template"
+ type = string
+ default = "email"
+ validation {
+ condition = contains(["sms", "dingding", "wechat", "webhook", "email"], var.sub_type)
+ error_message = "Type of template is not one of: sms, dingding, wechat, webhook, email"
+ }
+}
+
+variable "template_source" {
+ description = "The source of the notification template, currently, this parameter is mandatory to LTS"
+ type = string
+ default = "LTS"
+ validation {
+ condition = var.template_source == "LTS"
+ error_message = "Template source is not LTS"
+ }
+}
\ No newline at end of file
diff --git a/versions.tf b/versions.tf
index 74655e1..af0509e 100644
--- a/versions.tf
+++ b/versions.tf
@@ -1,3 +1,10 @@
terraform {
required_version = "~> 1.4"
+
+ required_providers {
+ huaweicloud = {
+ source = "huaweicloud/huaweicloud"
+ version = "~>1.47"
+ }
+ }
}