Your company has set up a CloudFront distribution.
They are using multiple EC2 Instances as the origin.
There is a requirement to ensure that cookies can be monitored in the requests.
Based on the cookies, different sites can be relayed back to the users.
Which of the following would help fulfill this requirement?
Click on the arrows to vote for the correct answer
A. B. C. D.Answer - B.
There are many uses for Lambda@Edge processing.
For example:
A Lambda function can inspect cookies and rewrite URLs so that users see different versions of a site for A/B testing.
CloudFront can return different objects to viewers based on the device they're using by checking the User-Agent header, including information about the devices.
For example, CloudFront can return different images based on the screen size of their device.
Similarly, the function could consider the value of the Referer header and cause CloudFront to return the images to bots that have the lowest available resolution.
Or you could check cookies for other criteria.
For example, on a retail website that sells clothing, if you use cookies to indicate which color a user chose for a jacket, a Lambda function can change the request so that CloudFront returns the image of a jacket in the selected color.
A Lambda function can generate HTTP responses when CloudFront viewer request or origin request events occur.
A function can inspect headers or authorization tokens and insert a header to control access to your content before CloudFront forwards the request to your origin.
A Lambda function can also make network calls to external resources to confirm user credentials or fetch additional content to customize a response.
Option A is incorrect since multiple origins will not help in the requirement.
Option C is incorrect since the proxy protocol is normally used with the Elastic Load Balancer.
Option D is incorrect since this is used for media streaming distributions.
For more information on using Lambda at the edge, please visit the following URL:
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-at-the-edge.htmlThe requirement is to monitor cookies in requests and relay different sites back to users based on the cookies. CloudFront is a content delivery network (CDN) service provided by AWS that allows you to distribute your content globally. When using CloudFront with multiple EC2 instances as the origin, there are several ways to fulfill the requirement.
Option A: Consider using multiple origins When using multiple origins, you can create a separate origin for each site that needs to be relayed back to the users. Each origin can be an EC2 instance or an S3 bucket. You can then configure CloudFront to route the requests to the appropriate origin based on the cookies. However, this approach can be complicated to manage if you have many sites to relay back to the users.
Option B: Consider using Lambda@Edge Lambda@Edge is a service provided by AWS that allows you to run Lambda functions at the edge locations of CloudFront. You can use Lambda@Edge to inspect the cookies in the requests and route them to the appropriate site. Lambda@Edge can also be used to modify the response headers to include information about the selected site. This approach is more flexible and easier to manage than using multiple origins.
Option C: Consider using proxy protocol The proxy protocol is a header-based protocol that provides information about the client connection to the origin server. When using proxy protocol, the client IP address and port number are passed in the headers to the origin server. This information can be used to route the requests to the appropriate site. However, this approach requires the origin server to support the proxy protocol.
Option D: Consider using RTMP distributions Real-Time Messaging Protocol (RTMP) is a protocol used for streaming audio, video, and data over the internet. When using RTMP distributions, you can use cookies to identify the stream and relay it back to the users. However, this approach is not suitable for serving static content.
In conclusion, option B is the best approach to fulfill the requirement as it provides more flexibility and is easier to manage than the other options. Lambda@Edge can inspect the cookies in the requests and route them to the appropriate site, and it can also modify the response headers to include information about the selected site.