AWS ALB(Application Load Balancer)未从VPC接收到所有流量可能由于以下原因:
resource "aws_lb" "example" {
name = "example"
internal = false
load_balancer_type = "application"
subnets = [
aws_subnet.example1.id,
aws_subnet.example2.id,
]
security_groups = [
aws_security_group.example.id,
]
}
resource "aws_security_group" "example" {
name = "example"
description = "Example security group"
ingress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_lb_target_group" "example" {
name = "example"
port = 80
protocol = "HTTP"
health_check {
protocol = "HTTP"
path = "/"
healthy_threshold = 2
unhealthy_threshold = 2
timeout = 3
interval = 30
}
}
resource "aws_lb_target_group_attachment" "example" {
target_group_arn = aws_lb_target_group.example.arn
target_id = aws_instance.example.id
port = 80
}
通过检查以上配置,并确保其正确性,可以解决AWS ALB未从VPC接收到所有流量的问题。