I am trying to implement a solution based on routing the request to a specific origin based on HTTP header on the request.
We are using CloudFront for caching, and we have attached 2 ALBs as origin. Now when the HTTP header has an old value, it should hit ALB1, and when the request header has a new value set, then it should hit ALB2.
Still deciding the plan.
CloudFront has two types of edge compute: CloudFront Functions and Lambda@Edge. CloudFront functions only supports viewer-facing (request/response) events, while Lambda@Edge supports both viewer-facing (request/response) and origin-facing (request/response).
Because you want to dynamically change the origin (host) that CloudFront routes the request to, you need to use an origin-request event. That means you'll need Lambda@Edge.
The process to do so is straightforward:
Example here — https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-examples.html#lambda-examples-content-based-routing-examples
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With