【发布时间】:2020-01-15 17:12:58
【问题描述】:
我正在尝试使用 Terraform 和 ALB 来配置 ECS 集群。目标为Unhealthy。控制台Health checks failed with these codes: [502]中的错误代码为502
我查看了 AWS 故障排除指南,但没有任何帮助。
编辑:我没有在 EC2 容器上运行任何服务/任务。它是一个普通的 ECS 集群。
这是我的 ALB 相关代码:
# Target Group declaration
resource "aws_alb_target_group" "lb_target_group_somm" {
name = "${var.alb_name}-default"
port = 80
protocol = "HTTP"
vpc_id = "${var.vpc_id}"
deregistration_delay = "${var.deregistration_delay}"
health_check {
path = "/"
port = 80
protocol = "HTTP"
}
lifecycle {
create_before_destroy = true
}
tags = {
Environment = "${var.environment}"
}
depends_on = ["aws_alb.alb"]
}
# ALB Listener with default forward rule
resource "aws_alb_listener" "https_listener" {
load_balancer_arn = "${aws_alb.alb.id}"
port = "80"
protocol = "HTTP"
default_action {
target_group_arn = "${aws_alb_target_group.lb_target_group_somm.arn}"
type = "forward"
}
}
# The ALB has a security group with ingress rules on TCP port 80 and egress rules to anywhere.
# There is a security group rule for the EC2 instances that allows ingress traffic to the ECS cluster from the ALB:
resource "aws_security_group_rule" "alb_to_ecs" {
type = "ingress"
/*from_port = 32768 */
from_port = 80
to_port = 65535
protocol = "TCP"
source_security_group_id = "${module.alb.alb_security_group_id}"
security_group_id = "${module.ecs_cluster.ecs_instance_security_group_id}"
}
有没有人遇到这个错误并且知道如何调试/修复这个?
【问题讨论】:
标签: amazon-web-services terraform amazon-ecs terraform-provider-aws