Implement the token check in a CloudFront Function with CloudWatch logging and continuous deployment
A video platform company is migrating its video catalog to AWS. The company will host MP4 videos files in an Amazon S3 bucket. The company will use Amazon CloudFront and Amazon EC2 instances to serve the video files. Users first connect to a frontend application that redirects to a video URL. The video URL contains an authorization token in CloudFront. The cache is activated on the CloudFront distribution. Authorization token check activity needs to be logged in Amazon CloudWatch. The company wants to prevent direct access to video files on CloudFront and Amazon S3 and wants to implement checks of the authorization token that the frontend application provides. The company also wants to perform regular rolling updates of the code that checks the authorization token signature. Which solution will meet these requirements with the LEAST operational effort?
Community Votes
100% of anonymous learners picked answer B. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
The check has to run at the CloudFront edge to satisfy both the protection requirement and the logging requirement, and CloudFront Functions are the lightweight edge runtime designed for exactly this kind of token validation (B). f4b18ba and Srikantha both identified CloudFront Functions as the low-overhead choice for simple authorization checks at the edge with low latency, which matters because the check runs on every request. CloudFront continuous deployment is the native mechanism for rolling out function code updates, which is what the regular rolling update requirement calls for (B). Option A uses Lambda@Edge, which is a heavier runtime that also requires replicated functions, and options C and D achieve rolling updates by standing up a second distribution and using Route 53 weighted routing, which is far more operational overhead.
The authorization token check must happen at the edge so that CloudFront and S3 can both be protected from direct access, the check activity must be logged to CloudWatch, and the checking code must support regular rolling updates. CloudFront Functions run JavaScript at the CloudFront edge, which is where the signed URL and token arrive, so the token is validated before CloudFront serves any content and origin access stays blocked. CloudFront Functions support CloudWatch logging, and because they are deployed as configuration associated with the distribution, updates are delivered through CloudFront continuous deployment, which performs the rolling update of the function code without manual distribution cutover.
Using Lambda@Edge for the token check (A) — matt200 noted Lambda@Edge is well suited to authorization checks and supports CloudWatch logging and rolling updates, so it is a defensible choice; however, Lambda@Edge requires replicated functions across Regions, uses Node.js or Python runtimes, and supports more complex logic than is needed for a token check, so its operational overhead exceeds that of CloudFront Functions for the same purpose. f4b18ba identified CloudFront Functions as the lightweight JavaScript environment designed for high performance with low latency and ideal for simple tasks like authorization checks. Creating a second CloudFront distribution and migrating traffic with Route 53 weighted routing (C and D) — this achieves a rolling update by duplicating the entire distribution and shifting DNS weight, which is a large amount of additional infrastructure to maintain compared with CloudFront continuous deployment. Implementing the check in application code on the EC2 instances behind CloudFront (C) — that places the check at the origin rather than the edge, so CloudFront can still be bypassed and direct origin access is not prevented.
Community Discussion (4 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
The solution must validate an authorization token at the edge so that CloudFront and Amazon S3 are both protected from direct access, must log the token-check activity to Amazon CloudWatch, and must support regular rolling updates of the checking code, all with the least operational effort. CloudFront Functions are a lightweight JavaScript runtime that executes at the CloudFront edge, which is exactly where the signed URL and its token arrive, so implementing the token check there validates the request before CloudFront serves any content and keeps origin access restricted (B). CloudFront Functions support CloudWatch logging, satisfying the logging requirement (B). For updates, CloudFront continuous deployment performs rolling deployments of the function code to the distribution without the team having to stand up parallel infrastructure, which is what the regular rolling update requirement calls for (B). f4b18ba identified CloudFront Functions as the lightweight, low-latency environment ideal for simple tasks such as authorization checks, and Srikantha noted the approach checks the token directly at the edge, minimizing latency, and integrates with CloudWatch logging and continuous deployment. uncledana confirmed it provides the least operational overhead. B is the correct answer.Why the Other Options Are Wrong
A implements the authorization token check in Lambda@Edge. matt200's assessment of Lambda@Edge is accurate on the capabilities, since it can perform token authorization checks, supports CloudWatch logging, handles more complex validation logic, integrates with CloudFront, and supports rolling updates via CloudFront continuous deployment. Its weakness is operational: Lambda@Edge functions must be replicated across Regions, run on the Node.js or Python runtime, and provide capabilities beyond what a token check requires. As f4b18ba framed it, CloudFront Functions is the lightweight JavaScript-based environment designed for high performance with low latency and is ideal for simple tasks like authorization checks, so the least-operational-effort requirement points to B. C implements the check in application code installed on the EC2 instances and adds CloudWatch logging through the CloudWatch agent, then creates a second CloudFront distribution and migrates traffic with Route 53 weighted routing. Putting the check in the origin application fails the core security requirement, because a check at the origin does not prevent requests from bypassing CloudFront and reaching S3 directly. D uses CloudFront Functions for the check, which is the correct runtime, but achieves the rolling update by creating a second CloudFront distribution and shifting traffic with Route 53 weighted routing, duplicating the entire distribution and adding DNS-based traffic management where CloudFront continuous deployment would simply roll the function code, so D carries substantially more operational overhead than B. B is correct.Community Comment Notes
Community voted B (88), with A a minority (12). f4b18ba identified CloudFront Functions as a lightweight JavaScript-based environment running at the edge, designed for high performance with low latency and ideal for simple tasks such as authorization checks. Srikantha explained that it checks the token directly at the edge, minimizing latency, and integrates seamlessly with CloudWatch logging and continuous deployment. uncledana confirmed it provides the least operational overhead across token validation, CloudWatch logging, and rolling updates. matt200 was the sole dissenter, favoring Lambda@Edge and citing its suitability for token authorization, CloudWatch logging, complex validation logic, CloudFront integration, and rolling updates; while each capability is accurate, Lambda@Edge carries additional operational cost for a simple token check, which is the decisive factor given the requirement. No alternative received majority support.Official Reference
Related Analysis
Practice All DOP-C02 Questions
Access 85 questions with complete answers and detailed explanations.
View Full DOP-C02 Practice Test →