Skip to content

Commit

Permalink
feat: Add module message template (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
Karina5005 authored Nov 8, 2023
1 parent f421e34 commit 0987982
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 1 deletion.
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,40 @@
# Module name
# Huawei Cloud LTS Message Template
<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.4 |
| <a name="requirement_huaweicloud"></a> [huaweicloud](#requirement\_huaweicloud) | ~>1.47 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_huaweicloud"></a> [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 |
|------|-------------|------|---------|:--------:|
| <a name="input_content"></a> [content](#input\_content) | Content of template | `string` | n/a | yes |
| <a name="input_locale"></a> [locale](#input\_locale) | Language | `string` | `"en-us"` | no |
| <a name="input_name"></a> [name](#input\_name) | Specifies the name of the template | `string` | n/a | yes |
| <a name="input_name_postfix"></a> [name\_postfix](#input\_name\_postfix) | Name Postfix | `string` | `null` | no |
| <a name="input_sub_type"></a> [sub\_type](#input\_sub\_type) | Type of the template | `string` | `"email"` | no |
| <a name="input_template_source"></a> [template\_source](#input\_template\_source) | The source of the notification template, currently, this parameter is mandatory to LTS | `string` | `"LTS"` | no |

## Outputs

No outputs.
<!-- END_TF_DOCS -->
14 changes: 14 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -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
}
}
45 changes: 45 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -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"
}
}
7 changes: 7 additions & 0 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
terraform {
required_version = "~> 1.4"

required_providers {
huaweicloud = {
source = "huaweicloud/huaweicloud"
version = "~>1.47"
}
}
}

0 comments on commit 0987982

Please sign in to comment.