☰ All modules Tier 4 · CloudFront GuideCheat sheet ‹ rdsroute53 ›
Contents
  1. How CloudFront appears on DVA-C02
  2. 1. Origins behaviors and origin failover
  3. 2. Cache keys policies TTLs and invalidations
  4. 3. Securing origins and content
  5. 4. Signed URLs signed cookies and key groups
  6. 5. Edge functions and real time logs
  7. Quick decision rules
  8. Changed vs older material

CloudFront — DVA-C02 Mastery Guide

  • Sources: course chapter 08 (CloudFront). The course serves as the syllabus only; all wording, examples and questions here are original. CloudFront Functions and Lambda@Edge are taught here because notes/lambda-guide.md defers them to this module.
  • Written 2026-10-12; values checked against AWS docs on 2026-10-12 (CloudFront Developer Guide, CloudFront API Reference, AWS CLI reference, AWS General Reference quotas). The marker ⚠️ Changed: <current>. Older material may say <old>. flags a value or behaviour that differs from the course or older practice tests: learn the current value. ⚠️ unverified marks a value that could not be confirmed or on which AWS pages disagree: never build an answer on it. (volatile) marks a value AWS changes often. Every change is listed in Changed vs older material; rows you confirm are added to notes/current-facts.md.
  • Tier 4 (skim: developer-facing features only), bank target 15 questions. Domains: Troubleshooting and Optimization (primary), Security.
  • How to use it: /explain <topic> teaches from these sections (concept → exam facts → developer angle → traps → 3 check questions); /quiz cloudfront asks bank questions whose source_note links point at the ## N. headings below; /drill cloudfront fires short recall prompts from notes/cloudfront-cheat-sheet.md. Suggested loop: read a section and answer its practice questions before opening the answers → /explain what is still unclear → /quiz cloudfront → /drill cloudfront.

How CloudFront appears on DVA-C02

DVA-C02 treats CloudFront as the caching and security layer a developer puts in front of an application, not as a CDN architecture topic. Questions ask what you configure and why a request behaves the way it does:

Typical question shapes: one scenario with one deciding constraint (LOWEST latency, LEAST operational overhead, MOST secure, MOST cost-effective); a status code or log symptom to diagnose; "Which TWO…" with five options; the exact setting, header, policy or CLI command that does the job.

Domain map: Troubleshooting and Optimization → §1 (origin errors, timeouts, failover), §2 (hit ratio, TTLs, invalidations), §5 (edge function errors, logs) · Security → §3 (origin protection, geo restriction, field-level encryption), §4 (signed URLs and cookies).

Out of scope here (owned by other modules): ACM certificates, SNI and TLS policies → notes/ec2-mastery-guide.md §9 (CloudFront viewer certificates live in us-east-1); S3 bucket policies, Cross-Region Replication, static website hosting, CORS and presigned URLs → notes/s3-guide.md §2, §5 and §9; KMS key policies → notes/security-encryption-guide.md §2; Route 53 alias records to a distribution → notes/route53-guide.md §2; security groups and prefix lists → notes/vpc-guide.md §2 and notes/ec2-mastery-guide.md §4; Lambda execution roles, versions and function URLs → notes/lambda-guide.md §4, §7 and §11; Kinesis Data Streams and Firehose → notes/sqs-sns-kinesis-guide.md §10 and §13; CloudWatch alarms → notes/monitoring-guide.md §5; API Gateway edge-optimized endpoints → notes/api-gateway-guide.md §2. Network design features (Anycast static IPs, BYOIP, multi-tenant distributions) are skipped.

# Topic Why it is on the exam
1 Origins behaviors and origin failover Route each path to the right origin; decode 502/503/504; timeouts and failover settings
2 Cache keys policies TTLs and invalidations Correct content with the highest hit ratio; stale content and how to refresh it
3 Securing origins and content OAC and KMS key policies, ALB protection, geo restriction, field-level encryption
4 Signed URLs signed cookies and key groups Paid or per-user content; canned vs custom policy; key rotation without the root user
5 Edge functions and real time logs CloudFront Functions vs Lambda@Edge; Lambda@Edge deployment rules; logs and metrics

1. Origins behaviors and origin failover

Concept

Exam facts

Developer angle

UpdateDistribution replaces the whole configuration and requires the current ETag:

aws cloudfront get-distribution-config --id E1A2B3C4D5E6F7 > current.json
ETAG=$(jq -r '.ETag' current.json)
jq '.DistributionConfig' current.json > config.json    # edit behaviors, origins, timeouts here
aws cloudfront update-distribution --id E1A2B3C4D5E6F7 \
  --if-match "$ETAG" --distribution-config file://config.json
aws cloudfront wait distribution-deployed --id E1A2B3C4D5E6F7   # polls every 60 s

Traps

Practice questions

  1. A developer changes the origin protocol policy of an internet-facing ALB origin from HTTP only to HTTPS only. Viewers immediately receive HTTP 502 responses with the header X-Cache: Error from cloudfront, although the targets behind the ALB are healthy. What is the MOST likely cause?

    • A. The ALB's HTTPS listener presents a self-signed certificate that does not match the origin domain name.
    • B. The ALB security group does not allow inbound HTTPS from the CloudFront origin-facing managed prefix list.
    • C. The 30-second origin response timeout is shorter than the time the application needs to build its responses.
    • D. The cache behavior's viewer protocol policy still allows both HTTP and HTTPS.
  2. A video platform uses an origin group with a primary and a secondary origin. When the primary is unreachable, viewers wait about 30 seconds before CloudFront serves segments from the secondary. Which TWO changes shorten this delay? (Select TWO.)

    • A. Increase the origin response timeout of the primary origin to 120 seconds.
    • B. Reduce the connection attempts of the primary origin to 1.
    • C. Reduce the connection timeout of the primary origin to 2 seconds.
    • D. Turn on Origin Shield for the primary origin.
    • E. Change the price class of the distribution to PriceClass_All.
Answers
  1. A. A failed TLS handshake with a custom origin (untrusted, expired or mismatched certificate) produces 502 with Error from cloudfront. B would show up as 504 timeouts, C causes 504 on slow responses, and D only concerns the viewer-to-CloudFront leg.
  2. B, C. The default wait is 3 attempts × 10 s; fewer attempts and a shorter connection timeout make CloudFront give up on the primary sooner. A only lengthens waits on slow responses, D adds a caching layer without changing how long CloudFront waits for an unreachable primary, and E changes edge coverage, not origin timing.

2. Cache keys policies TTLs and invalidations

Concept

Exam facts

Developer angle

A cache policy that varies only by the page query string (policy.json), then a batch invalidation (IAM: cloudfront:CreateInvalidation on arn:aws:cloudfront::<account-id>:distribution/<id>; in a pipeline, upload the hashed asset names first, then invalidate only /index.html):

{ "Name": "catalog-page-key", "MinTTL": 0, "DefaultTTL": 300, "MaxTTL": 3600,
  "ParametersInCacheKeyAndForwardedToOrigin": { "EnableAcceptEncodingGzip": true, "EnableAcceptEncodingBrotli": true,
    "HeadersConfig": { "HeaderBehavior": "none" }, "CookiesConfig": { "CookieBehavior": "none" },
    "QueryStringsConfig": { "QueryStringBehavior": "whitelist", "QueryStrings": { "Quantity": 1, "Items": ["page"] } } } }
aws cloudfront create-cache-policy --cache-policy-config file://policy.json
aws cloudfront create-invalidation --distribution-id E1A2B3C4D5E6F7 \
  --paths "/index.html" "/images/*" "#catalog:shoes"    # quote wildcards; "#tag" items need a CacheTagConfig

Traps

Practice questions

  1. A product catalog origin chooses the page to render only from the page query string parameter. Marketing links add utm_source and utm_campaign parameters with many different values. Which cache policy setting returns correct pages with the highest cache hit ratio?

    • A. Query strings: All.
    • B. Query strings: include only page.
    • C. Query strings: None.
    • D. Query strings: all except page.
  2. A team deploys a single-page application to an S3 origin that uses the CachingOptimized cache policy. After each release, some users keep running the previous JavaScript bundle for up to a day. Which TWO actions deliver new releases quickly at the LOWEST ongoing cost? (Select TWO.)

    • A. Schedule an invalidation of /* every five minutes with an EventBridge rule.
    • B. Attach the CachingDisabled cache policy to the default behavior.
    • C. Add a content hash to the JavaScript and CSS file names and reference them from index.html.
    • D. Create an invalidation for /index.html as the last step of each deployment.
    • E. Change the price class of the distribution to PriceClass_100.
Answers
  1. B. Only page changes the response, so only page belongs in the key. A splits the cache on tracking values, C serves the same page for every page value, and D keys on the tracking parameters while dropping the one that matters.
  2. C, D. New file names bypass every cache, and invalidating the small entry document makes users load the new names. A invalidates constantly and triggers cache-miss storms, B sends every request to S3 (cost and latency), and E only reduces edge coverage.

3. Securing origins and content

Concept

Exam facts

Developer angle

Bucket policy for an OAC-protected origin, then the OAC itself and the Lambda function URL grant (run add-permission again with --action lambda:InvokeFunction and a new statement ID). Attach the OAC with update-distribution by setting OriginAccessControlId on the origin and clearing OriginAccessIdentity:

{ "Version": "2012-10-17", "Statement": [{ "Sid": "ReadThroughOneDistribution", "Effect": "Allow",
    "Principal": { "Service": "cloudfront.amazonaws.com" }, "Action": "s3:GetObject",
    "Resource": "arn:aws:s3:::media-assets-prod/*",
    "Condition": { "StringEquals": { "AWS:SourceArn": "arn:aws:cloudfront::111122223333:distribution/E1A2B3C4D5E6F7" } } }] }
aws cloudfront create-origin-access-control --origin-access-control-config Name=media-oac,SigningProtocol=sigv4,SigningBehavior=always,OriginAccessControlOriginType=s3
aws lambda add-permission --function-name thumbs-api --statement-id cf-oac-url \
  --action lambda:InvokeFunctionUrl --principal cloudfront.amazonaws.com \
  --source-arn arn:aws:cloudfront::111122223333:distribution/E1A2B3C4D5E6F7

Traps

Practice questions

  1. A developer switches the objects in an S3 bucket origin to SSE-KMS with a customer managed key. The distribution uses OAC, and the bucket policy already allows cloudfront.amazonaws.com with the distribution's ARN as AWS:SourceArn. Every object now returns HTTP 403 through CloudFront. What should the developer do?

    • A. Replace the OAC with an origin access identity and grant that identity read access in the bucket policy.
    • B. Disable S3 Block Public Access on the bucket and add a statement that makes every object publicly readable.
    • C. Allow cloudfront.amazonaws.com to use kms:Decrypt in the KMS key policy, scoped by AWS:SourceArn.
    • D. Change the signing behavior of the OAC to no-override so that the credentials sent by viewers reach S3.
  2. A company serves an application through CloudFront from an internet-facing ALB. Security requires that the ALB accept requests only when they come through this distribution, without application code changes and with the LEAST operational overhead. Which TWO actions meet these requirements? (Select TWO.)

    • A. Configure CloudFront to add a secret custom origin header, and add an ALB listener rule that forwards only requests carrying it, with a fixed 403 default action.
    • B. Enable geo restriction on the distribution with an allow list of the company's countries.
    • C. Create an origin access control of type s3 and attach it to the ALB origin.
    • D. Allow inbound HTTPS on the ALB security group only from the com.amazonaws.global.cloudfront.origin-facing managed prefix list.
    • E. Schedule a Lambda function that rewrites the ALB security group from the published ip-ranges.json file.
Answers
  1. C. With SSE-KMS, CloudFront needs permission on the key as well as on the bucket. A fails because OAI does not support SSE-KMS, B weakens security and still leaves the key unusable for anonymous reads, and D only changes when CloudFront signs: viewers send no SigV4 credentials, and the key policy still denies CloudFront.
  2. A, D. The secret header proves a request came from CloudFront, and the managed prefix list blocks non-CloudFront sources with no maintenance. B filters CloudFront viewers by country and does nothing against requests sent straight to the ALB, C applies only to S3, Lambda URL and Elemental origins, and E rebuilds what the managed prefix list already does, adding operational overhead.

4. Signed URLs signed cookies and key groups

Concept

Exam facts

Developer angle

Create the key pair and the key group (pubkey-config.json holds CallerReference, Name and EncodedKey, the PEM text; then put the key group ID into the behavior's TrustedKeyGroups with update-distribution), and sign in the application with the AWS SDK for JavaScript v3 (getSignedCookies from the same package returns the cookie values):

openssl genrsa -out private_key.pem 2048
openssl rsa -pubout -in private_key.pem -out public_key.pem
aws cloudfront create-public-key --public-key-config file://pubkey-config.json   # returns PublicKey.Id
aws cloudfront create-key-group --key-group-config Name=premium-signers,Items=K2JCJMDEHXQW5F
import { getSignedUrl } from "@aws-sdk/cloudfront-signer";
const signedUrl = getSignedUrl({ url: "https://d111111abcdef8.cloudfront.net/premium/ep01.mp4",
  keyPairId: "K2JCJMDEHXQW5F",                    // public key ID from the trusted key group
  privateKey: process.env.CLOUDFRONT_PRIVATE_KEY,  // injected from Secrets Manager at startup; never commit it
  dateLessThan: new Date(Date.now() + 15 * 60 * 1000).toISOString() });

Traps

Practice questions

  1. A streaming service delivers HLS video to subscribers through CloudFront. Each title consists of a manifest and hundreds of segment files whose URLs the player builds from the manifest, so the application cannot change them. Which approach restricts the videos to signed-in subscribers with the LEAST development effort?

    • A. Generate a CloudFront signed URL for every segment file and rewrite each manifest on every request.
    • B. Generate S3 presigned URLs for every segment file by using the IAM role of the application servers.
    • C. Enable geo restriction with an allow list of the countries where the service is sold.
    • D. Issue signed cookies with a custom policy whose resource is a wildcard for the title's path.
  2. A team signs CloudFront URLs with a CloudFront key pair that the root user created years ago. A new policy forbids root user activity and requires key rotation every 90 days without breaking URLs that are still valid. Which TWO actions should the developer take? (Select TWO.)

    • A. Replace the CloudFront signed URLs with S3 presigned URLs created with an IAM user's access keys.
    • B. Upload a new public key with create-public-key, add it to a trusted key group on the cache behavior, and sign with its private key.
    • C. Delete the old public key from the key group as soon as the new key is uploaded.
    • D. Store the private key as an object in the origin bucket so that every application server can read it.
    • E. At each rotation, add the new public key to the key group, switch signing to it, and remove the old key after the longest URL lifetime.
Answers
  1. D. One set of signed cookies with a wildcard resource covers every file of the title without touching URLs. A needs per-segment signing and manifest rewriting, B bypasses CloudFront and still changes every URL, and C restricts by country, not by subscription.
  2. B, E. Key groups are managed through the API and IAM without the root user, and the add–switch–wait–remove order keeps outstanding URLs valid. A uses long-term IAM user keys and skips the edge cache, C breaks URLs that are still valid, and D exposes the private key.

5. Edge functions and real time logs

Concept

Exam facts

Capability CloudFront Functions Lambda@Edge
Runtime and events JavaScript: cloudfront-js-1.0 (ES 5.1 base) or cloudfront-js-2.0 (adds const/let, async/await, Buffer and KeyValueStore; ⚠️ Changed: since 2023-11-21. Older material may say ES 5.1 only, no data store); viewer request and viewer response only Node.js or Python; viewer request, viewer response, origin request, origin response
Run time and scale Sub-millisecond, reported as compute utilization 0–100; millions of requests per second Origin events up to 30 s; viewer events ⚠️ unverified: up to 30 s per the CloudFront Developer Guide, 5 s per the General Reference quota table (older material: 5 s); 10,000 requests per second per Region, sharing that Region's Lambda concurrency (1,000 by default)
Memory and code size 2 MB; 10 KB of code, not adjustable (keep data in KeyValueStore) 128 MB on viewer events, up to 10,240 MB on origin events; ⚠️ Changed: 50 MB compressed on every event. Older material may say 1 MB on viewer events.
Network, file system, request body None Yes (Include body: base64, truncated at 40 KB on viewer and 1 MB on origin events)
Data and viewer headers KeyValueStore (runtime 2.0; store ≤ 5 MB, key ≤ 512 bytes, value ≤ 1 KB, 1 store per function); geolocation and device headers available Any AWS service through the SDK; CloudFront geolocation and device headers only on origin events

Developer angle

The lifecycle of a viewer request function (runtime 2.0) that maps directory URLs to index.html on an S3 REST origin, and the numbered version that a Lambda@Edge association needs:

aws cloudfront create-function --name dir-index --function-config Comment="Append index.html",Runtime=cloudfront-js-2.0 --function-code fileb://dir-index.js
ETAG=$(aws cloudfront describe-function --name dir-index --query ETag --output text)
aws cloudfront test-function --name dir-index --if-match "$ETAG" --stage DEVELOPMENT --event-object fileb://event.json
aws cloudfront publish-function --name dir-index --if-match "$ETAG"          # DEVELOPMENT -> LIVE
aws lambda publish-version --function-name origin-router --region us-east-1  # put the returned FunctionArn (...:origin-router:7) in LambdaFunctionAssociations

Traps

Practice questions

  1. An e-commerce site receives product URLs whose query parameters arrive in random order and mixed case, which lowers the cache hit ratio. A developer wants to sort and lowercase the parameters before CloudFront looks up the cache, at the LOWEST latency and cost. What should the developer do?

    • A. Associate a CloudFront Function with the viewer request event.
    • B. Associate a Lambda@Edge function with the origin request event.
    • C. Associate a Lambda@Edge function with the viewer request event.
    • D. Change the cache policy to include all query strings in the cache key.
  2. A developer wrote a Node.js function in eu-west-1 and tries to associate arn:aws:lambda:eu-west-1:111122223333:function:origin-router:$LATEST with the origin request event of a cache behavior. CloudFront rejects the association. Which TWO actions are required? (Select TWO.)

    • A. Configure reserved concurrency on the function so that CloudFront can scale it.
    • B. Re-create the function in the US East (N. Virginia) Region.
    • C. Create an alias named live and associate the alias ARN instead.
    • D. Publish a version of the function and associate the numbered version ARN.
    • E. Attach the function to a VPC in each Region where it will run.
Answers
  1. A. Normalisation must happen before the cache lookup, and a CloudFront Function on viewer request is the cheapest, fastest place for header and query string rewrites. B runs after the lookup and only on misses, C works but costs more and adds latency, and D lowers the hit ratio further.
  2. B, D. Lambda@Edge functions must live in us-east-1 and be referenced by a numbered version. A does not affect the association, C fails because aliases are not accepted, and E is impossible because Lambda@Edge does not support VPC access.

Quick decision rules

Origins and caching (§1–§2)

Security (§3–§4)

Edge code and logs (§5)

Changed vs older material

Learn the Current column; older practice material may still show the Course / older material value. Rows you confirm during /ingest are added to notes/current-facts.md.

Topic Course / older material Current (verified 2026-10-12) Source
§1 · Cache behaviors and origins per distribution 25 behaviors, 25 origins 75 behaviors and 100 origins per distribution (adjustable) AWS docs
§1 · Origin response timeout 1–60 s, default 30 s 1–120 s, default 30 s, higher through a quota request; optional response completion timeout (2025-07-30) AWS docs
§1 · Largest cacheable object 30 GB (earlier 20 GB) 50 GB per GET response AWS docs
§1 · Origin failover status codes 400, 403, 404, 416, 500, 502, 503, 504 Adds 429 AWS docs
§1 · Pricing model Pay-as-you-go with three price classes Price classes unchanged (PriceClass_All, PriceClass_200, PriceClass_100); flat-rate plans Free, Pro, Business, Premium since 2025-11-18 AWS docs
§2 · Policy options and naming Cache policy headers None–Whitelist; origin request policy None–Whitelist–All Console "Include specified/following"; API still whitelist; origin request policies add "all except" block lists (2023-02-22) AWS docs
§2 · TTL range 0 s to 1 year MinTTL required (0 allowed); DefaultTTL defaults to 86,400 s and MaxTTL to 31,536,000 s; longer values allowed (max-age up to 100 years) AWS docs
§2 · Invalidating everything * /*: API and CLI invalidation paths must start with / (only the console accepts them without) AWS docs
§2 · Invalidation methods Paths and wildcards (/*, /images/*) Also cache tags: CacheTagConfig + #tag items in CreateInvalidation AWS docs
§2 · Invalidation quotas 3,000 file paths and 15 wildcard paths in progress ⚠️ unverified: quota page says 150 paths or tags per second and 1 wildcard per second; General Reference still says 3,000 / 15 AWS docs
§3 · S3 origin access Origin access identity (OAI) OAC recommended (SSE-KMS, PUT/DELETE, all Regions); OAI legacy; OAC also for Lambda function URLs (2024-04-11) AWS docs
§3 · Restricting an ALB or EC2 origin Allow the published edge IP ranges in the security group Managed prefix list com.amazonaws.global.cloudfront.origin-facing (2022-02-07) plus a secret header, or VPC origins (2024-11-20) AWS docs
§3 · Field-level encryption status Presented as a current feature, up to 10 fields Still up to 10 fields; AWS lists it among legacy features not supported on flat-rate plans AWS docs
§3 · Client certificates from viewers CloudFront cannot authenticate viewers with certificates Viewer mutual TLS since 2025-11-24 (trust stores; required, optional or passthrough mode) AWS docs
§4 · Signers Account-wide CloudFront key pair managed by the root user Trusted key groups (API and IAM, recommended); root key pairs legacy, at most 2 active AWS docs
§4 · Keys and hash algorithm RSA 2048 with SHA-1 RSA 2048 or ECDSA 256; optional SHA-256 via Hash-Algorithm (default SHA-1) AWS docs
§5 · Lambda@Edge package size on viewer events 1 MB 50 MB compressed on every event AWS docs
§5 · Lambda@Edge timeout on viewer events 5 s ⚠️ unverified: Developer Guide says up to 30 s; General Reference quota table still says 5 s AWS docs
§5 · CloudFront Functions runtime and data ES 5.1 only, no data store Runtime 2.0 (selected ES6–ES12 features, async/await) and KeyValueStore (2023-11-21) AWS docs
§5 · Changing the origin per request Only a Lambda@Edge origin request function Also CloudFront Functions helpers cf.updateRequestOrigin() (2024-11-21) and cf.selectRequestOriginById() (2025-04-02) AWS docs
§5 · Standard log destinations An S3 bucket only; Firehose called Kinesis Data Firehose Standard logging v2 (2024-11-20): CloudWatch Logs, Amazon Data Firehose or S3; legacy S3 logging still available AWS docs