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:
You create a Lambda @Edge function with a source request trigger.
The Lambda function is triggered when CloudFront sends a request to the primary origin (in a cache failure).
The primary source responds with an HTTP status code configured for failover.
The Lambda function is triggered again when CloudFront sends the same request to the secondary origin.