0

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.

2
  • 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
    – Tim
    Jul 10 at 23:51
  • 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
    – John Heyer
    Jul 12 at 1:45
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.