- Newest
- Most votes
- Most comments
You can do this using Lambda@Edge using CloudFront. The Lambda function could use a Route 53 hostname in it to make it more resilient and easy to modify the weights + hostnames of DCs.
To add -
If the incoming request doesn't have that specific header, you can let Lambda@Edge do the routing based on the routing_logic. Once the request is mapped to a backend, you would want to stick a cookie (session/persistent) in the browser with that Origin value.
When subsequent requests come to CloudFront, your logic would be like:
{
IF:
Request Header: A
THEN:
Go to, Origin = A
}
{
IF:
Request Header: B
THEN:
Go to, Origin = B
}
Even for the above snippet that I shared, my vote would be to 'not' hardcode A and B Origin hostnames in Lambda functions and still create R53 failover properties, and use them in there. The advantage is that; if A goes down, the failover property would automatically send the requests to the failover target.
Relevant content
- asked 4 years ago
- Accepted Answerasked 10 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated a year ago