I have an API running on Elastic Beanstalk. The API has endpoints that will do different things depending on the location of the user requesting it.
I see that Route53 has a geolocation feature, and my understanding is that it can route to different EC2 instances based on location.
My case is that I have one EC2 instance running my API, and I want to route to different endpoints (or even could pass the location as an argument) according to the location.
Can I use Route53 to do that? If not, is there another way to do that for an API running in Elastic Beanstalk like I have?
For what its worth, the API is a Flask Python API..
That Route53 feature really isn’t intended to be used like you are describing. It won’t route a request to a different path on a server based on the location, it simply routes all requests to a completely different server (usually in a completely different country) based on location.
What I would do is place CloudFront in front of your API, and use one of the CloudFront location headers, like
CloudFront-Viewer-Country-Region or even the Latitude/Longitude request headers that CloudFront adds to the requests it proxies to your API.
From there you could have a single API endpoint that checks that header and then calls different code execution paths in your backend code based on the location.