I have an ECS container on Fargate that needs to connect to an EC2 instance that hosts a web service. Both the Fargate container and the EC2 instance are on the same VPC and subnet, and the subnet is public.
If I provide the container the Private IPv4 DNS name of said EC2 instance, the connection is successful. However, the EC2 instance is connected to an ALB, and that has a Route 53 name connected to it (which also works fine).
If I provide the Route 53 DNS name to the Fargate container, the connection is unsuccessful.
What configuration do I need to look into to get the Fargate container to resolve the Route 53 DNS name to the EC2 instance?
So, for example, I have a Route 53 A record: https://my-app.com. This record is bound to an ALB, which in turn is bound to the EC2 instance that's hosting APP-1. This record works as expected on the browser.
My Fargate container, hosting APP-2, in its configuration you can provide the URL to connect to APP-1.
When providing APP-2 with the URL ip-10-0-0-10.us-east-1.compute.internal (this representing the private DNS name), it does resolve (as expected), since the VPC has both enableDnsHostnames
and enableDnsSupport
enabled.
When providing APP-2 with the URL https://my-app.com (the Route 53 A record), it does not resolve (times out). The subnet (where both the EC2 and Fagate container resides) has an Internet Gateway set up in the route table.