I have followed this tutorial: https://www.youtube.com/watch?v=o7s-eigrMAI to learn to setup my Load Balancer that connects to Fargate. I have also followed this answer: AWS Error : None of these Availability Zones contains a healthy target. Requests are being routed to all targets. in AWS
To check if my security groups have been linked properly.
However, after setting it up, when I try to access my load balancer URL, I get a 502 Bad Gateway error.
I have checked on the monitoring tab on my load balancer and I can see that there was a request coming in.
I have 2 security groups:
- VPC Security Group (ECS) - sg-05c038a61c8a39401
- EC2 Security Group (Load Balancer) - sg-0d50dc5f42650f6b6
What I have done:
- Navigated to the Service under my Cluster and clicked on the Security group. This brings me to the VPC Security Group
- In the VPC Security group, under the inbound rules, I changed the type to All traffic and source to the EC2 Security Group
- Navigate to the EC2 screen and click on Security Group under Network Access
- In the EC2 Security Group, under outbound rules, I changed the type to all traffic and destination to the VPC Security Group
My logic is that since the traffic comes into the EC2 Load Balancer, its outbound should be directed to the VPC Security Group
NOTE:
I am able to access the service using the IP address directly
Also, I noticed that my target groups show this error and are constantly draining:
None of these Availability Zones contains a healthy target. Requests are being routed to all targets.
And after a few minutes, I get this error when I try to access the DNS URL:
503 Service Temporarily Unavailable