data "aws_autoscaling_group" "asg" { name = var.asg-name } resource "aws_cloudwatch_metric_alarm" "asg-CPUUtilization" { alarm_name = "${var.settings.CPUUtilization.ecccode}-ASG_${var.asg-name}-CPUUtilization" comparison_operator = var.settings.CPUUtilization.comparison_operator evaluation_periods = var.settings.CPUUtilization.evaluation_periods metric_name = "CPUUtilization" period = var.settings.CPUUtilization.period statistic = var.settings.CPUUtilization.statistic threshold = var.settings.CPUUtilization.threshold alarm_description = "ASG:CPUUtilization" namespace = "AWS/EC2" insufficient_data_actions = [] actions_enabled = var.actions-enabled alarm_actions = [var.settings.CPUUtilization.action] ok_actions = [var.settings.CPUUtilization.action] dimensions = { AutoScalingGroupName =var.asg-name } } 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 } }