terraform.aws-baseline-infra/modules/ManagementGovernance/Monitoring.NLB/main.tf

32 lines
1.1 KiB
Terraform
Raw Normal View History

data external nlb-targetgroups {
program = ["bash", "../../modules/ManagementGovernance/Monitoring.NLB/list-nlb-targetgroups.sh"]
query = {
lb = var.load-balancer
}
}
resource aws_cloudwatch_metric_alarm nlb-HealthyHostCount {
for_each = toset(split(" ", data.external.nlb-targetgroups.result.result))
alarm_name = "NLBTG:HealthyHostCount:${split("/", each.value)[1]}/${split("/", each.value)[2]}"
comparison_operator = "LessThanThreshold"
evaluation_periods = "1"
metric_name = "HealthyHostCount"
period = "300"
statistic = "Minimum"
threshold = var.threshold-HealthHostCountMin
alarm_description = "NLBTG:HealthyHostCount"
namespace = "AWS/NetworkELB"
insufficient_data_actions = []
actions_enabled = "true"
alarm_actions = [var.alarm-actions-emergency]
ok_actions = [var.alarm-actions-emergency]
dimensions = {
TargetGroup = "targetgroup/${split("/", each.value)[1]}/${split("/", each.value)[2]}"
LoadBalancer = "net/${split("/",var.load-balancer)[2]}/${split("/",var.load-balancer)[3]}"
}
tags = var.default-tags
lifecycle {
ignore_changes = [tags]
}
}