2022-10-25 19:51:04 +08:00
|
|
|
/*
|
|
|
|
data "external" "nlb-targetgroups" {
|
|
|
|
program = ["bash", "${path.module}/list-nlb-targetgroups.sh"]
|
2022-10-25 14:21:37 +08:00
|
|
|
query = {
|
2022-10-25 19:51:04 +08:00
|
|
|
parameter = var.load-balancer
|
2022-10-25 14:21:37 +08:00
|
|
|
}
|
|
|
|
}
|
2022-10-25 19:51:04 +08:00
|
|
|
*/
|
2022-10-25 14:21:37 +08:00
|
|
|
|
2022-10-25 19:51:04 +08:00
|
|
|
|
|
|
|
module "nlb-targetgroups" {
|
|
|
|
source = "../../util/resource-list"
|
|
|
|
resource-type = "nlb-targetgroups"
|
|
|
|
query-input = var.load-balancer
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_cloudwatch_metric_alarm" "nlb-HealthyHostCount" {
|
|
|
|
for_each = module.nlb-targetgroups.result-set
|
|
|
|
alarm_name = "NLBTG:HealthyHostCount:${split(":", each.value)[5]}"
|
|
|
|
comparison_operator = "LessThanThreshold"
|
|
|
|
evaluation_periods = "1"
|
|
|
|
metric_name = "HealthyHostCount"
|
|
|
|
period = "300"
|
|
|
|
statistic = "Minimum"
|
|
|
|
threshold = var.threshold-HealthHostCountMin
|
|
|
|
alarm_description = "NLBTG:HealthyHostCount"
|
|
|
|
namespace = "AWS/NetworkELB"
|
2022-10-25 14:21:37 +08:00
|
|
|
insufficient_data_actions = []
|
2022-10-25 19:51:04 +08:00
|
|
|
actions_enabled = "true"
|
|
|
|
alarm_actions = [var.alarm-actions-emergency]
|
|
|
|
ok_actions = [var.alarm-actions-emergency]
|
2022-10-25 14:21:37 +08:00
|
|
|
dimensions = {
|
2022-10-25 19:51:04 +08:00
|
|
|
TargetGroup = split(":", each.value)[5]
|
|
|
|
LoadBalancer = "net/${split("/", var.load-balancer)[2]}/${split("/", var.load-balancer)[3]}"
|
2022-10-25 14:21:37 +08:00
|
|
|
}
|
|
|
|
tags = var.default-tags
|
|
|
|
lifecycle {
|
|
|
|
ignore_changes = [tags]
|
|
|
|
}
|
|
|
|
}
|