Use Route 53 Latency-Based Routing:
- Create a Hosted Zone for your domain name in Route 53
- Create Record Set of type
CNAME
, a value of the DNS Name or IP address of one of your instances, and a Routing Policy of Latency
. Select the Region where that instance is located.
- Repeat for the second instance.
That's it! The domain name will then automatically redirect to the instance with the lowest latency connection.
It is advisable to use Elastic IP Addresses in case the instances are ever stopped (which could cause the IP address to change).
It is not possible to "provide only one IP which will target to both the instances" -- instead, you need to use the domain name, which will resolve to one of the IP addresses of your two instances.