I have a lambda function in all AWS regions. I have clients throughout the globe who will make a POST call to my base domain example.com
. It is the responsibility of my (kind-of) load-balancer to make sure that the requests are routed to the API gateway of the region which is closest to the client, in order to minimize the latency.
So, far I have the following configuration:
- Lambda functions deployed on each region
- Custom domain names for each of the API gateways, which exposes a CloudFront domain name. For instance, N.California region has custom domain name
us-west-1.example.com
configured and a mapping of the path which calls my lambda. The CloudFront URL for this API gateway isd12345123.cloudfront.net
- A RecordSet of type
A
in the Route53 hosted zone forus-west-1.example.com
which is an alias ofd12345123.cloufront.net
. If I make a POST call tous-west-1.example.com/1.0/localdb
, it returns me the correct output. - A traffic policy in Route53 and a policy record, for
default.example.com
ofA
type, which has a geo-proximity rule assigned to it, which redirects the traffic to the CloudFront instance (the same instance which is exposed after adding the custom domain name in that region) of the region. This creates an entry fordefault.example.com
in the hosted zone of typeA
- A RecordSet of type
A
in the Route53 hosted zone forexample.com
which is an alias todefault.example.com
, so that the traffic which comes toexample.com
can be routed todefault.example.com
After these configurations, when I make a call to example.com
, I receive a 403
response from Cloudfront, calling it a Bad Request
Thanks