How to maintain active/active endpoint with Cloudfront? - amazon-web-services

Recently AWS had a biggest outage with S3 on US-east-1. We would like to expand to multiple regions now deploying lambda and S3 data to other regions. I would like to retain one single url that can detect if the region has an outage and forward the call to the active region. If both regions are active, closest region will receive the request.
I tried with AWS Route53 and it did not help with https. Since Cloudfront cannot accept the same cname on more than one distribution.

Related

AWS Outage Reroute

I am stuck on a possible implementation for a problem I am facing in AWS.
I have multiple websites that are hosted with S3 using CloudFront in us-east-1. If there is an outage in that region, I want to reroute traffic from those UIs to a website hosted with S3 using CloudFront in another region (just a basic error page, all UIs from us-east-1 need to be rerouted to the same one error page in the new region).
After doing research, I am seeing a lot of documentation for Route 53 DNS Failover handling. However, we don't use Route 53 for traffic routing, so I don't think these solutions apply for this particular problem. Does anyone have any advice on possible solutions?
Using CloudFront's Origin Groups feature, you can group the two S3 endpoints and configure the criteria for when CloudFront should failover to the secondary origin (e.g., 500-504 error). When you create your cache behavior, you'll use the Origin Group as your origin. Details: Optimizing high availability with CloudFront origin failover

AWS Route53 - How to route rest requests to appropriate apigateway in different regions based on url endpoints

I have API gateway configured in us-east-1 and us-west-1 to serve rest service requests. Also,i have a Route53 which is on failover policy. Only us-east-1 is primary, it will be failed over to us-west-1 only when health check failed in us-east-1. As i'm planning to make things active-active, i need to route the read calls to both the regions, however write calls to only us-east-1 as primary. Is it possible to achieve this requirement? Can i route the traffic of my rest service requests based on url parameters.
Is it possible to achieve this requirement?
No. Route53 does not participate in your API's read or write operations. It does not differentiate between them, thus it can't "direct" read operations different that write operations.

Will route53 choose the closest region to serve the request?

I am planning to deploy my api gateway to multiple regions in AWS. I implement a health endpoint in the gateway in each region and configure them in route53 healthy check. So route53 will forward the request to the healthy regions if one region fails on healthy check.
My question is in case of all regions are healthy, will route53 route traffic to the closest region? For example, if there are 2 regions configured in route53, ap-southeast-1 and ap-southeast-2, can route53 route the traffic to ap-southeast-2 if the request is from Sydney since it is closer? If yes, how does route53 decide which one is closer?
Yes, you can do that using Route 53 Geolocation routing policy, which can be used when you want to serve your site based on the location of the client or user.
There are three routing policies in R53 that you may consider:
Geolocation routing policy – Use when you want to route traffic based on the location of your users.
Geoproximity routing policy – Use when you want to route traffic based on the location of your resources and, optionally, shift traffic from resources in one location to resources in another.
Latency routing policy – Use when you have resources in multiple AWS Regions and you want to route traffic to the region that provides the best latency.
how does route53 decide which one is closer?
Geolocation is based the location that DNS queries originate from.
Geoproximity routing lets Amazon Route 53 route traffic to your resources based on the geographic location of your users and your resources.
Latency-based routing is based on latency measurements performed over a period of time.
For all these, AWS can also use EDNS0 edns-client-subnet extension.

How can I use cloudwatch metric for `Latency-based` routing policy in route53?

I am deploying applications in AWS multiple regions. There are a few lambdas sitting behind API gateway. And I'd like to use route53 routing policy to route traffic to different regions.
The policy I'd like to use is Latency-based policy which means route53 routes traffic to resources based on its response time. I have read this doc https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy.html and https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-values-latency.html.
It works a little different than my thought. What I am looking for is the use the latency based on the response time in my API gateway or ALB. But based on the doc, it seems that latency is based on DNS resolve name server. Is there a way for me to use the latency based on cloudwatch metric like IntegrationLatency?

AWS replace EC2 with CloudFront

I have a domain dev-www.myexample.de hosted via AWS EC2 and a Load Balancer. I want to replace this configuration with an S3 bucket + CloudFront and keep same domain name.
The only possible way I could find was destroying my EC2 instance and Route 53 and then deploy my CloudFront and domain and this works fine.
However, I want to show a 503 page for all traffic that comes while my EC2 instance is down and before my CloudFront and S3 bucket are ready to use. Any idea how I can do that?
You can create your Amazon S3 bucket and Amazon CloudFront distribution before changing the DNS configuration. This gives you an opportunity to ensure that it is working correctly.
Then, you can change the Route 53 configuration to point to CloudFront instead of the Load Balancer. It will take some time for this change to propagate throughout the Internet, during which cached queries will continue to go to the Load Balancer but new DNS lookups will go to CloudFront. If you have the same content in both locations, there should not be a need to display any notice.
Please note that only static content can be served from Amazon S3, so if you had any back-end logic in your Amazon EC2 servers, it would not be possible to continue providing it with CloudFront + S3.