[Infrastructure as Code (IaC)] Terraform Aliyun Monitor Examples about using Terraform Alibaba Cloud Provider to manage alarm rules and monitor sites
Terraform Aliyun Monitor Examples
Examples about using Terraform Alibaba Cloud Provider to manage alarm rules and monitor sites.
Github: https://github.com/CloudoLife/terraform-aliyun-monitor-examples
Prerequsites
Your must have a Alibaba Cloud account with Access Key, and Terraform CLI have been installed.
Aliyun Account and Access Key
-
Alibaba Cloud Document Center: Find the Documentation for Your Needs - Alibaba Cloud
Before you purchase and use Alibaba Cloud products and services, you must have an Alibaba Cloud account. And then configure the account.
-
Create an AccessKey - General Reference| Alibaba Cloud Documentation Center
An AccessKey is equivalent to a logon password, but they are used in different scenarios. AccessKeys are used to directly call APIs, while logon passwords are used to log on to the console. You must create an AccessKey only if you must call APIs.
Terrraform and Terrafrom Aliyun Provider
-
Use Infrastructure as Code to provision and manage any cloud, infrastructure, or service
-
Provider: alicloud - Terraform by HashiCorp
The Alibaba Cloud provider is used to interact with the many resources supported by Alibaba Cloud. The provider needs to be configured with the proper credentials before it can be used.
Configuration
Profile and Region
First, Specify your Aliyun(AliCloud - Alibaba Cloud) profile and region within terraform.tfvars.
1 | # terraform.tfvars |
CMS Alarm Rules
See more within cms_alarm.tf.
1 | # Alicloud: alicloud_cms_alarm - Terraform by HashiCorp |
CMS Site Monitor
See more within cms_site_monitor.tf.
1 | # Alicloud: alicloud_cms_site_monitor - Terraform by HashiCorp |
Run
Terraform Init
1 | terraform init |
It will download the Terraform Alibaba Cloud Provider binary.
Terraform apply
1 | terraform apply |
It will dispaly the execute plan and wait for your make yes or no.
Known issues
- alicloud_cms_alarm ‘notify_type’ has been removed from provider version 1.50.0.
Because currently Terraform Alibaba Cloud Provider only supports the setting of Critical rules, other levels are not yet supported.
1
2
3
4
Error: "notify_type": [REMOVED] Field 'notify_type' has been removed from provider version 1.50.0.
on main.tf line 6, in resource "alicloud_cms_alarm" "basic":
6: resource "alicloud_cms_alarm" "basic" {
-
May auto create a new alarm rule while update the some alarm rules provided by Terrraform within AliCloud Web Console.
-
Config alarm rule within alicloud_cms_site_monitor is not supported.
Reference
[3] Terraform-阿里云 - https://help.aliyun.com/product/95817.html
[4] OpenAPI Explorer - https://api.aliyun.com/#/cli?tool=Terraform