Score:0

AWS ALB Shows Target Group unhealthy, even though port 80 is open to Internet

ng flag

I've built an AWS ALB & Target group via Terraform and everything looks correct but the Target Group is reporting unhealthy for HTTP, HTTPS, and TCP. The instance is a t3.nano in us-east-2 and has Nginx installed and running.

I've verified the following:

  • Nginx is configured and running on ports 80 & 443
  • Security groups allow HTTP & HTTPS from 0.0.0.0/0
  • Instance is on a public subnet (that is, the 0.0.0.0/0 route is to the IGW)

If I access the instance's public IP from Internet, and the "Welcome to nginx!" page is displayed. This request shows up both in /var/log/nginx/access.log. tcpdump port 80 shows requests coming from Internet but nothing indicating an AWS healthcheck.

I've used ALBs and Target groups before and never encountered an issue like this. The only difference is this instance was created with Terraform.

Tim avatar
gp flag
Tim
When you have an ALB the instances should be in a private subnet with no public IP. Not sure what the problem is though, I'd have to poke around and see what's happening. I wonder if the ALB refuses to connect to public instances? Probably not but worth checking
John Heyer avatar
ng flag
Interesting thing is if I change the target group from 'instance' to 'ip address' and manually enter the IP address of the instance, it works fine
Score:0
ca flag

I think you need to configure the target_type parameter in your lb_target_group resource. The default value is instance, that configuration requires use autoscaling_group for EC2 instances. If you use aws_instance for EC2, you need use ip parameter.

https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group#target_type

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.