-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudwatch.tf
46 lines (40 loc) · 1.56 KB
/
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
## Lambda log groups
resource "aws_cloudwatch_log_group" "dns_register" {
name = "/aws/lambda/dns_register"
retention_in_days = 30
}
resource "aws_cloudwatch_log_group" "dns_deregister" {
name = "/aws/lambda/dns_deregister"
retention_in_days = 30
}
## Scaling alarms
resource "aws_cloudwatch_metric_alarm" "network-high" {
alarm_name = format("%s-network-high", var.service_name)
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "1"
metric_name = "NetworkOut"
namespace = "AWS/EC2"
period = "60"
statistic = "Average"
threshold = var.scale_up_networkIn_threshold_in_bytes
alarm_description = format("Monitors %s instance network for high utilization.", var.service_name)
alarm_actions = [aws_autoscaling_policy.up.arn]
dimensions = {
AutoScalingGroupName = aws_autoscaling_group.this.name
}
}
resource "aws_cloudwatch_metric_alarm" "memory-low" {
alarm_name = format("%s-network-low", var.service_name)
comparison_operator = "LessThanOrEqualToThreshold"
evaluation_periods = "1"
metric_name = "NetworkOut"
namespace = "AWS/EC2"
period = "60"
statistic = "Average"
threshold = var.scale_down_networkIn_threshold_in_bytes
alarm_description = format("Monitors %s instance network for low utilization.", var.service_name)
alarm_actions = [aws_autoscaling_policy.down.arn]
dimensions = {
AutoScalingGroupName = aws_autoscaling_group.this.name
}
}