Skip to content

Terraform module which creates MNS topic and its subscription on Alibaba Cloud

License

Notifications You must be signed in to change notification settings

alibabacloud-automation/terraform-alicloud-mns-topic

Repository files navigation

Alicloud MNS Queue Terraform Module
terraform-alicloud-mns-topic

This Terraform module will create a topic and a subcription.

These types of resources are supported:


Usage

You can use this in your terraform template with the following steps.

  1. Adding a module resource to your template, e.g. main.tf
module "mns-topic" {
  source = "terraform-alicloud-modules/mns-topic/alicloud"

  #variables for  topic
  topic_name                        = "tf-example-mnstopic"
  maximum_message_size              =65536
  logging_enabled                   =true

  #variables for  subscription
  subscription_name                 ="tf-example-mnstopic-subscription"
  endpoint                          ="http://localhost:7001/notifyback.htm"
  filter_tag                        ="Test"
  notify_strategy                   ="BACKOFF_RETRY"
  notify_content_format             ="XML" 
}
  1. Setting access_key and secret_key values through environment variables:

    • ALICLOUD_ACCESS_KEY
    • ALICLOUD_SECRET_KEY
    • ALICLOUD_REGION

Inputs

Name Description Type Default Required
topic_name The name of topic. string "" yes
maximum_message_size This indicates the maximum length, in bytes, of any message body sent to the topic. int 65536 no
loggin_enabled is log enabled bool false no
subscription_name The name of queue. string "" yes
endpoint Describe the terminal address of the message received in this subscription. string no yes
notify_strategy The NotifyStrategy attribute of Subscription. string "BACKOFF_RETRY" no
notify_content_format The NotifyContentFormat attribute of Subscription. string "XML" no
filter_tag Describe the terminal address of the message received in this subscription. string "" no

Outputs

Name Description
topic_name the name of topic created
subscription_name the name of subscription created

Notes

From the version v1.2.0, the module has removed the following provider setting:

provider "alicloud" {
   version              = ">=1.56.0"
   region               = var.region != "" ? var.region : null
   configuration_source = "terraform-alicloud-modules/mns-topic"
}

If you still want to use the provider setting to apply this module, you can specify a supported version, like 1.1.0:

module "mns-topic" {
   source               = "terraform-alicloud-modules/mns-topic/alicloud"
   version              = "1.1.0"
   region               = "cn-beijing"
   topic_name           = "tf-example-mnstopic"
   maximum_message_size = 65536
   // ...
}

If you want to upgrade the module to 1.2.0 or higher in-place, you can define a provider which same region with previous region:

provider "alicloud" {
   region = "cn-beijing"
}
module "mns-topic" {
   source               = "terraform-alicloud-modules/mns-topic/alicloud"
   topic_name           = "tf-example-mnstopic"
   maximum_message_size = 65536
   // ...
}

or specify an alias provider with a defined region to the module using providers:

provider "alicloud" {
   region = "cn-beijing"
   alias  = "bj"
}
module "mns-topic" {
   source               = "terraform-alicloud-modules/mns-topic/alicloud"
   providers            = {
      alicloud = alicloud.bj
   }
   topic_name           = "tf-example-mnstopic"
   maximum_message_size = 65536
   // ...
}

and then run terraform init and terraform apply to make the defined provider effect to the existing module state.

More details see How to use provider in the module

Terraform versions

Name Version
terraform >= 0.13.0
alicloud >= 1.56.0

Authors

Created and maintained by Alibaba Cloud Terraform Team([email protected])

Reference

About

Terraform module which creates MNS topic and its subscription on Alibaba Cloud

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •