2023-05-23 13:10:16 +08:00
|
|
|
data "aws_autoscaling_group" "asg" {
|
|
|
|
name = var.asg-name
|
|
|
|
}
|
|
|
|
|
2022-10-26 11:13:56 +08:00
|
|
|
resource "aws_cloudwatch_metric_alarm" "asg-CPUUtilization" {
|
2023-05-23 13:10:16 +08:00
|
|
|
alarm_name = "${var.settings.CPUUtilization.ecccode}-ASG_${var.asg-name}-CPUUtilization"
|
2023-01-05 23:35:31 +08:00
|
|
|
comparison_operator = var.settings.CPUUtilization.comparison_operator
|
|
|
|
evaluation_periods = var.settings.CPUUtilization.evaluation_periods
|
2022-10-26 11:13:56 +08:00
|
|
|
metric_name = "CPUUtilization"
|
2023-01-05 23:35:31 +08:00
|
|
|
period = var.settings.CPUUtilization.period
|
|
|
|
statistic = var.settings.CPUUtilization.statistic
|
|
|
|
threshold = var.settings.CPUUtilization.threshold
|
2022-10-26 11:13:56 +08:00
|
|
|
alarm_description = "ASG:CPUUtilization"
|
|
|
|
namespace = "AWS/EC2"
|
|
|
|
insufficient_data_actions = []
|
|
|
|
actions_enabled = var.actions-enabled
|
2023-01-05 23:35:31 +08:00
|
|
|
alarm_actions = [var.settings.CPUUtilization.action]
|
|
|
|
ok_actions = [var.settings.CPUUtilization.action]
|
2022-10-26 11:13:56 +08:00
|
|
|
dimensions = {
|
2023-05-23 13:10:16 +08:00
|
|
|
AutoScalingGroupName =var.asg-name
|
2022-10-26 11:13:56 +08:00
|
|
|
}
|
|
|
|
}
|
2023-05-23 13:10:16 +08:00
|
|
|
|
|
|
|
resource "aws_cloudwatch_metric_alarm" "asg-GroupInServiceCapacity" {
|
|
|
|
alarm_name = "${var.settings.GroupInServiceCapacity.ecccode}-ASG_${var.asg-name}-GroupInServiceCapacity"
|
|
|
|
comparison_operator = "LessThanThreshold"
|
|
|
|
evaluation_periods = var.settings.GroupInServiceCapacity.evaluation_periods
|
|
|
|
metric_name = "GroupInServiceCapacity"
|
|
|
|
period = var.settings.GroupInServiceCapacity.period
|
|
|
|
statistic = "Minimum"
|
|
|
|
threshold = data.aws_autoscaling_group.asg.min_size
|
|
|
|
alarm_description = "ASG:GroupInServiceCapacity"
|
|
|
|
namespace = "AWS/AutoScaling"
|
|
|
|
insufficient_data_actions = []
|
|
|
|
actions_enabled = var.actions-enabled
|
|
|
|
alarm_actions = [var.settings.GroupInServiceCapacity.action]
|
|
|
|
ok_actions = [var.settings.GroupInServiceCapacity.action]
|
|
|
|
dimensions = {
|
|
|
|
AutoScalingGroupName = var.asg-name
|
|
|
|
}
|
|
|
|
}
|