-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcloudwatch.tf
28 lines (24 loc) · 908 Bytes
/
cloudwatch.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
# Lambda function logs
resource "aws_cloudwatch_log_group" "main" {
name = "/aws/lambda/${var.name}"
retention_in_days = 7
}
# Scale-out and scale-in alarm
resource "aws_cloudwatch_metric_alarm" "main" {
count = length(var.scaling_policy)
alarm_name = "${var.name}-${count.index}"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = "1"
namespace = "AWS/DocDB"
metric_name = var.scaling_policy[count.index].metric_name
statistic = var.scaling_policy[count.index].statistic
period = tostring(var.scaling_policy[count.index].cooldown)
threshold = tostring(var.scaling_policy[count.index].target)
# Actions
actions_enabled = "true"
alarm_actions = [aws_sns_topic.main.arn]
ok_actions = [aws_sns_topic.main.arn]
dimensions = {
DBClusterIdentifier = var.cluster_identifier
}
}