forked from alibabacloud-automation/terraform-alicloud-redis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
163 lines (154 loc) · 7.09 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
locals {
this_instance_id = var.existing_instance_id != "" ? var.existing_instance_id : concat(alicloud_kvstore_instance.this.*.id, [""])[0]
create_more_resources = var.create_instance
create_account = local.create_more_resources && var.create_account
project = "acs_kvstore"
}
resource "alicloud_kvstore_instance" "this" {
count = var.create_instance ? 1 : 0
ssl_enable = var.ssl_enable
instance_type = "Redis"
engine_version = var.engine_version
db_instance_name = var.instance_name
instance_class = var.instance_class
zone_id = var.availability_zone
secondary_zone_id = var.secondary_zone_id
security_group_id = var.security_group_id
instance_release_protection = var.instance_release_protection
vswitch_id = var.vswitch_id
security_ips = var.security_ips
payment_type = var.instance_charge_type
period = var.period
auto_renew = var.auto_renew
auto_renew_period = var.auto_renew_period
private_ip = var.private_ip
backup_id = var.instance_backup_id
vpc_auth_mode = var.vpc_auth_mode
password = var.password
kms_encrypted_password = var.kms_encrypted_password
kms_encryption_context = var.kms_encryption_context
maintain_start_time = var.maintain_start_time
maintain_end_time = var.maintain_end_time
config = length(var.config) > 0 ? var.config : null
tags = var.tags
}
resource "alicloud_kvstore_backup_policy" "this" {
count = local.create_more_resources ? 1 : 0
instance_id = local.this_instance_id
backup_period = var.backup_policy_backup_period
backup_time = var.backup_policy_backup_time
}
module "accounts" {
source = "./modules/account"
create_account = local.create_account
redis_instance_id = local.this_instance_id
accounts = var.accounts
}
resource "alicloud_cms_alarm" "sharding_cpu_usage" {
count = local.create_more_resources && var.enable_alarm_rule ? 1 : 0
enabled = var.enable_alarm_rule
name = var.alarm_rule_name
project = local.project
metric = "ShardingCpuUsage"
metric_dimensions = "[{\"instanceId\":\"${local.this_instance_id}\",\"device\":\"/dev/vda1\"}]"
escalations_critical {
statistics = var.alarm_rule_statistics
comparison_operator = var.alarm_rule_operator
threshold = var.alarm_rule_threshold
times = var.alarm_rule_triggered_count
}
period = var.alarm_rule_period
contact_groups = var.alarm_rule_contact_groups
silence_time = var.alarm_rule_silence_time
effective_interval = var.alarm_rule_effective_interval
}
resource "alicloud_cms_alarm" "sharding_connection_usage" {
count = local.create_more_resources && var.enable_alarm_rule ? 1 : 0
enabled = var.enable_alarm_rule
name = var.alarm_rule_name
project = local.project
metric = "ShardingConnectionUsage"
metric_dimensions = "[{\"instanceId\":\"${local.this_instance_id}\",\"device\":\"/dev/vda1\"}]"
escalations_critical {
statistics = var.alarm_rule_statistics
comparison_operator = var.alarm_rule_operator
threshold = var.alarm_rule_threshold
times = var.alarm_rule_triggered_count
}
period = var.alarm_rule_period
contact_groups = var.alarm_rule_contact_groups
silence_time = var.alarm_rule_silence_time
effective_interval = var.alarm_rule_effective_interval
}
resource "alicloud_cms_alarm" "sharding_max_rt" {
count = local.create_more_resources && var.enable_alarm_rule ? 1 : 0
enabled = var.enable_alarm_rule
name = var.alarm_rule_name
project = local.project
metric = "ShardingMaxRt"
metric_dimensions = "[{\"instanceId\":\"${local.this_instance_id}\",\"device\":\"/dev/vda1\"}]"
escalations_critical {
statistics = var.alarm_rule_statistics
comparison_operator = var.alarm_rule_operator
threshold = var.alarm_rule_threshold
times = var.alarm_rule_triggered_count
}
period = var.alarm_rule_period
contact_groups = var.alarm_rule_contact_groups
silence_time = var.alarm_rule_silence_time
effective_interval = var.alarm_rule_effective_interval
}
resource "alicloud_cms_alarm" "sharding_memory_usage" {
count = local.create_more_resources && var.enable_alarm_rule ? 1 : 0
enabled = var.enable_alarm_rule
name = var.alarm_rule_name
project = local.project
metric = "ShardingMemoryUsage"
metric_dimensions = "[{\"instanceId\":\"${local.this_instance_id}\",\"device\":\"/dev/vda1\"}]"
escalations_critical {
statistics = var.alarm_rule_statistics
comparison_operator = var.alarm_rule_operator
threshold = var.alarm_rule_threshold
times = var.alarm_rule_triggered_count
}
period = var.alarm_rule_period
contact_groups = var.alarm_rule_contact_groups
silence_time = var.alarm_rule_silence_time
effective_interval = var.alarm_rule_effective_interval
}
resource "alicloud_cms_alarm" "sharding_used_connection" {
count = local.create_more_resources && var.enable_alarm_rule ? 1 : 0
enabled = var.enable_alarm_rule
name = var.alarm_rule_name
project = local.project
metric = "ShardingUsedConnection"
metric_dimensions = "[{\"instanceId\":\"${local.this_instance_id}\",\"device\":\"/dev/vda1\"}]"
escalations_critical {
statistics = var.alarm_rule_statistics
comparison_operator = var.alarm_rule_operator
threshold = var.alarm_rule_threshold
times = var.alarm_rule_triggered_count
}
period = var.alarm_rule_period
contact_groups = var.alarm_rule_contact_groups
silence_time = var.alarm_rule_silence_time
effective_interval = var.alarm_rule_effective_interval
}
resource "alicloud_cms_alarm" "sharding_used_memory" {
count = local.create_more_resources && var.enable_alarm_rule ? 1 : 0
enabled = var.enable_alarm_rule
name = var.alarm_rule_name
project = local.project
metric = "ShardingUsedMemory"
metric_dimensions = "[{\"instanceId\":\"${local.this_instance_id}\",\"device\":\"/dev/vda1\"}]"
escalations_critical {
statistics = var.alarm_rule_statistics
comparison_operator = var.alarm_rule_operator
threshold = var.alarm_rule_threshold
times = var.alarm_rule_triggered_count
}
period = var.alarm_rule_period
contact_groups = var.alarm_rule_contact_groups
silence_time = var.alarm_rule_silence_time
effective_interval = var.alarm_rule_effective_interval
}