Amazon CloudFront - Failover using Lambda@Edge

You can use Lambda @Edge functions with CloudFront distributions that you have configured with origin groups. To use a Lambda function, specify it in an origin request trigger or source response from an origin group when creating the cache behavior. When using a Lambda @Edge function with a source group, it can be triggered twice for a single viewer request. For example, consider this scenario:

  1. You create a Lambda @Edge function with a source request trigger.

  2. The Lambda function is triggered when CloudFront sends a request to the primary origin (in a cache failure).

  3. The primary source responds with an HTTP status code configured for failover.

  4. The Lambda function is triggered again when CloudFront sends the same request to the secondary origin.

Origins Groups with Lambda@Edge


References