diff --git a/README.md b/README.md index 7234d11..0927b1d 100644 --- a/README.md +++ b/README.md @@ -1 +1,40 @@ -# Module name \ No newline at end of file +# Huawei Cloud SMN + +## 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_smn_subscription.emails](https://registry.terraform.io/providers/huaweicloud/huaweicloud/latest/docs/resources/smn_subscription) | resource | +| [huaweicloud_smn_topic.topic](https://registry.terraform.io/providers/huaweicloud/huaweicloud/latest/docs/resources/smn_topic) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [emails](#input\_emails) | Specifies the subscriptions emails | `list(string)` | `[]` | no | +| [topic\_name](#input\_topic\_name) | Specifies the name of the topic to be created | `string` | n/a | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| [topic\_id](#output\_topic\_id) | The ID of a created topic | +| [topic\_name](#output\_topic\_name) | The ID of a created topic | + \ No newline at end of file diff --git a/main.tf b/main.tf index e69de29..3ac6cbe 100644 --- a/main.tf +++ b/main.tf @@ -0,0 +1,11 @@ +resource "huaweicloud_smn_topic" "topic" { + name = var.topic_name +} + +resource "huaweicloud_smn_subscription" "emails" { + for_each = toset(var.emails) + + topic_urn = huaweicloud_smn_topic.topic.id + endpoint = each.value + protocol = "email" +} \ No newline at end of file diff --git a/outputs.tf b/outputs.tf index e69de29..fad1b24 100644 --- a/outputs.tf +++ b/outputs.tf @@ -0,0 +1,9 @@ +output "topic_id" { + description = "The ID of a created topic" + value = huaweicloud_smn_topic.topic.id +} + +output "topic_name" { + description = "The ID of a created topic" + value = huaweicloud_smn_topic.topic.name +} \ No newline at end of file diff --git a/variables.tf b/variables.tf index e69de29..9b40845 100644 --- a/variables.tf +++ b/variables.tf @@ -0,0 +1,10 @@ +variable "topic_name" { + description = "Specifies the name of the topic to be created" + type = string +} + +variable "emails" { + description = "Specifies the subscriptions emails" + type = list(string) + default = [] +} \ 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" + } + } }