CloudFront offers a built-in geographic restriction setting and AWS WAF offers a geo match rule. What can each do that the other cannot, and what would you tell a stakeholder who calls either one a compliance guarantee?
answer
- one setting for the entire distribution
- a rule can carry conditions a toggle cannot
- free versus billed per inspected request
- country comes from the IP address
- VPNs make it a control, not proof
basics
~20 sCloudFront geo restriction is a free country allowlist or blocklist applied to the whole distribution. A WAF geo match rule is per-rule, combinable with path and rate conditions, and costs WAF pricing. Both infer country from IP address, so neither is authoritative.
solid answer
~50 sCloudFront's geographic restriction is a distribution-level setting: one allowlist or blocklist of country codes that applies to every cache behavior, costs nothing, and returns 403 to blocked viewers. Its virtue is simplicity and its limit is bluntness — you cannot restrict `/eu-catalog/*` while leaving `/status` open. A **WAF geo match** statement is a rule condition, so it can be scoped to specific URI paths, combined with rate limits, IP sets or header checks, set to allow, block or count, and given a custom response — at the price of AWS WAF charges and the operational weight of a web ACL. Use the built-in setting for a whole-distribution policy, WAF when the rule is conditional. On the compliance question, be direct: both resolve the viewer's IP address to a country using a geolocation database, so VPNs, proxies, corporate egress and misattributed ranges defeat or misclassify it. It is a reasonable control, not proof of a user's location.
go deeper
Know that CloudFront can allow or block viewers by country, that the built-in setting covers the whole distribution, and that the country is inferred from the viewer's IP address.
Contrast the two mechanisms concretely: the distribution-level toggle is free and blunt, while a WAF geo match statement can be scoped to paths, combined with other conditions, counted before enforcing, and given a custom response — for WAF pricing.
Demonstrate the operational judgment: run it in count mode first, plan for travelling customers and corporate egress, and be explicit with stakeholders that IP geolocation is a good-faith control rather than evidence of location.
Own where territorial entitlement is actually decided. Argue for identity and billing as the authoritative layer with geo filtering as a cheap first pass, and set the position the organisation takes when a contract asks for a guarantee the network layer cannot give.
## The built-in setting CloudFront's geographic restriction lives on the distribution. You choose allowlist or blocklist and supply a set of country codes; CloudFront resolves the viewer's IP address to a country and refuses blocked viewers with a 403 before serving anything, cached or not. It costs nothing extra and takes a minute to configure. Its constraint is granularity. The setting is one policy for the entire distribution, applied to every cache behavior and every path. There is no way to express "block these countries for the video paths but always allow the health check and the public marketing pages." If your requirement has an exception in it, this feature cannot express it. ## The WAF geo match rule Inside an AWS WAF web ACL, a geo match statement is one condition among many. That changes what you can express: - Scope it with a byte-match on the URI so it applies to `/catalog/*` and nothing else. - Combine it with a rate-based rule, so a country is not blocked outright but is rate-limited harder. - Combine it with an IP set exception so partner egress ranges are exempt. - Set the action to **Count** first, and read the logs to see how much real traffic the rule would have hit before you enforce it. - Return a custom status code and body instead of a bare 403, which matters when a client application needs to distinguish "blocked by policy" from "broken". - Get per-request logging of which rule matched, which the built-in setting does not give you. The cost is real: WAF bills per web ACL, per rule, and per million requests inspected, so on a high-volume distribution a geo rule is not free the way the built-in toggle is. ## They share the same weakness Both resolve the client IP address against a geolocation database. That database is good, and for aggregate traffic it is right the overwhelming majority of the time — but the failure modes are systematic rather than random: - A commercial VPN or proxy presents an exit address in whatever country the user selected. Bypassing geo restriction is a consumer feature, not a hacking skill. - Corporate networks backhaul traffic, so an employee in one country appears in the country of the egress point. - Mobile carriers and CGNAT pools can be registered in one country while serving another. - A genuine customer travelling abroad is blocked from content they are entitled to, and will open a support ticket. - IP-to-country mappings change as ranges are reassigned, so a rule that was accurate a year ago drifts. Because both are country-granularity only, "this state but not that one" is not expressible either — although CloudFront can pass the viewer's inferred location onward in headers such as `CloudFront-Viewer-Country` and `CloudFront-Viewer-Country-Region`, so an edge function or the origin can make a finer-grained decision from the same inference. ## What to tell the stakeholder Say plainly that geo restriction is a control, not evidence. It reduces casual out-of-territory access and satisfies a good-faith-effort requirement in many licensing contracts, and that is genuinely worth having. It does not establish where a person is, and it will both let some people through and shut some legitimate customers out. If the contract or regulation demands a stronger claim, that claim has to rest on identity — an account with a verified billing address and a payment instrument in the territory — with geo filtering layered on top as a cheap first pass. Deciding which layer is authoritative is the real design conversation; the toggle is just the easy part.
- You must block one country for the paid video paths but keep the public marketing pages open worldwide. Which mechanism, and why?The WAF geo match rule. CloudFront's built-in geographic restriction applies to the whole distribution with no path scoping, so it cannot express the exception. In WAF you combine the geo statement with a URI byte-match so it only evaluates on the video paths, run it in count mode first, then enforce.
- How would an origin or an edge function get at the viewer's inferred country?CloudFront can add viewer-location headers such as CloudFront-Viewer-Country to the request, and they must be configured to travel through to the function or the origin. That lets you make a finer decision — a different catalog, a currency, a consent banner — from the same IP-based inference, without turning it into a hard block at the edge.
- What does a blocked viewer actually see with the built-in setting?A 403 from CloudFront, returned before any content is served, cached or not. That is fine for a browser but opaque for an API client, which is one reason teams move the rule into WAF: a WAF block action can return a custom status code and body that a client application can interpret and surface properly.
saying these in an interview costs you the question
- Treats IP geolocation as proof of a user's location
- Thinks CloudFront geo restriction can be set per cache behavior
- Assumes a WAF geo rule costs nothing extra
- Believes a VPN user cannot get around either mechanism
- Ignores legitimate customers who travel abroad