AWS CloudFront Events for Lambda@Edge | Exam SAA-C03

AWS CloudFront Events that trigger Lambda@Edge functions

Prev Question Next Question

Question

Which of the following are AWS CloudFront events that can trigger AWS Lambda@edge function? (choose 3 options)

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E.

Answer: A, D, E.

https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-cloudfront-trigger-events.html
CloudFront cache
<oee *:
one

1B Viewer response (Borigin response

AWS CloudFront is a content delivery network service provided by AWS, that enables faster delivery of static and dynamic content, such as HTML, CSS, images, and videos, from a web application to end-users around the globe. AWS Lambda@Edge is an extension of AWS Lambda, that allows developers to run serverless functions in response to CloudFront events, and execute custom logic for each end-user request.

There are several CloudFront events that can trigger a Lambda@Edge function, and based on the event type, different actions can be taken. Here are the explanations of the three CloudFront events that can trigger a Lambda@Edge function:

  1. Viewer Request: This event occurs when a viewer (end-user) sends a request to CloudFront, and before the request is forwarded to the origin server. A Lambda@Edge function triggered by this event can inspect and modify the viewer request, and either allow or deny the request based on custom business logic. For example, you can use this event to block requests from certain IP addresses or to redirect requests to a different URL.

  2. Origin Request: This event occurs when CloudFront sends a request to the origin server, on behalf of the viewer, to fetch the content. A Lambda@Edge function triggered by this event can modify the headers or parameters of the request before it is sent to the origin server. This can be used, for example, to add custom headers for authentication or to rewrite the URL to fetch a different version of the content.

  3. Origin Response: This event occurs when CloudFront receives a response from the origin server, and before the response is forwarded to the viewer. A Lambda@Edge function triggered by this event can modify the response body or headers, and add or remove content. For example, you can use this event to compress the response body, to add security headers, or to customize the content for each viewer based on their location.

The following CloudFront events are not valid triggers for Lambda@Edge:

  • CloudFront Cache: This event occurs when CloudFront retrieves content from its cache, and is not related to a viewer request.
  • Sender Request: This is not a valid CloudFront event.