AWS负载均衡器(ALB)健康检查的实现可以通过配置目标组中的'健康检查设置”完成。以下是一个示例:
resource "aws_alb_target_group" "test_target_group" {
name_prefix = "test-target-group"
port = 80
protocol = "HTTP"
vpc_id = "vpc-123456789"
target_type = "instance"
health_check {
healthy_threshold = 2
unhealthy_threshold = 2
timeout = 3
interval = 30
path = "/"
matcher = "200"
}
}
在上面的示例中,我们定义了一个名为'test-target-group”的目标组,并配置了'健康检查”设置。其中,'健康检查”相关设置包括:
此外,还可以通过标签(Tags)参数实现更多相关配置。
配置完成后,ALB会自动在目标组中的每个注册的目标上运行健康检查并自动切换到健康的目标。