📋 In This Post
Lab Overview
An internet-facing endpoint receives traffic nobody wrote code for. Path scanners looking
for /wp-admin and .env. Log4Shell probes in headers. A single IP
sending thousands of requests a minute at an endpoint sized for dozens.
The problem. The application usually does not break. It degrades, it bills, and it logs nothing useful about who did it. The team finds out from a latency graph, not from a security signal. There is no layer between the internet and the application that can say "no" before the request costs you compute.
The objective. Put that layer in — at the edge and at the origin — and find out what Shield Standard already does for free, and what it cannot see.
The outcome. Shield Standard is already on and there is nothing to deploy. The gap it leaves is layer 7. Two of the three things that went wrong planned cleanly and were completely inert.
| Difficulty | Advanced |
| Lab runtime | Four days before teardown |
| Measured cost | $4.93 — and the correction behind that number is in Troubleshooting |
| Deployment | Terraform via HCP Terraform with OIDC |
| Full lab guide | GitHub — prerequisites, Terraform, commands, validation, cleanup |
Cloud Services and Concepts
| Service | Purpose here | What it is |
|---|---|---|
| AWS Shield Standard | Layer 3 and 4 DDoS protection. Already on, for every AWS customer, at no cost. There is nothing to deploy — which is exactly why its limits are worth knowing. | Always-on protection against network and transport layer floods, included for every account at no charge. There is nothing to deploy and it does not read HTTP. |
| AWS WAF | The layer 7 firewall Shield Standard does not provide. Two web ACLs: one at the edge, one at the origin. | A web application firewall. Rules are evaluated in order against each request, and each rule can block, allow or merely count. |
| Amazon CloudFront | The edge the first web ACL protects. | A content delivery network. Requests land at an edge location near the caller, which answers from cache or forwards to your origin. |
| API Gateway REST API | The origin. REST, not HTTP API — a hard constraint, see below. | A managed front door for HTTP requests. The REST flavour is the older and dearer one, and it is the only flavour AWS WAF can attach to. |
| CloudWatch + SNS | Blocked-request alarms, and the notification when the firewall acts. | CloudWatch watches a metric and decides when it is wrong; SNS is how that decision reaches a person. |
Count mode versus Block mode is the whole deployment strategy. In Count mode a rule records what it would have done without rejecting anything. Going straight to Block is what produces the day-one outage that gets WAF disabled permanently.
WCUs (Web ACL Capacity Units) are the budget. 1,500 are included per web ACL, and AWS's own CommonRuleSet alone is 700. Check the sum before adding a managed group, because the ceiling arrives sooner than it sounds.
WAF cannot be associated with an API Gateway HTTP API at all. The supported types are CloudFront, API Gateway REST APIs, ALB, AppSync, Cognito user pools and App Runner. That constraint decides the architecture rather than being a detail of it.
Architecture and Workflow
- Shield Standard absorbs layer 3/4 volumetric attacks at the AWS edge, always, with nothing configured.
- A request reaches CloudFront, where the edge web ACL evaluates it.
- A break-glass IP set is evaluated before the managed rule groups, so a legitimate client caught by a false positive can be let through without disabling a rule for everyone.
- Managed rule groups run — in Count mode first, Block mode only once the sampled requests show what they would have rejected.
- Allowed requests reach the API Gateway REST API, where a second, regional web ACL evaluates them again.
- WAF logs are redacted at source and blocked-request metrics drive a CloudWatch alarm to SNS.
Design decisions
Two web ACLs, not one. An edge-only WAF protects only requests that actually travel through CloudFront. The API Gateway invoke URL stays publicly reachable — CloudFront does not hide it. Anyone who finds that URL walks straight past an edge-only firewall. The regional ACL is what makes the bypass pointless, and the attack simulation tests both paths for exactly that reason.
REST API, not HTTP API. Not a preference — WAF cannot attach to an HTTP API.
Count mode first, everywhere. The managed rules are deployed observing before they are deployed enforcing.
Prerequisites
| Requirement | Detail |
|---|---|
| AWS account | Permission for WAFv2, CloudFront, API Gateway, Lambda, CloudWatch, SNS |
| Terraform | >= 1.10. Note the provider gap in Troubleshooting |
| HCP Terraform | Workspace with OIDC to AWS. No static keys |
| Regions | Edge ACL must be created in us-east-1 regardless of where the origin lives |
Budget the WCUs before you choose rule groups. 1,500 included per web ACL; CommonRuleSet alone consumes 700. This build used 953 of 1,500 across five rules.
WAF bills by the hour, prorated. $5 per web ACL per month and $1 per rule per month are monthly rates, not minimums — two web ACLs cost roughly 2.7 cents an hour. Build, test thoroughly and destroy the same day and it costs well under a dollar.
Implementation
Two web ACLs, a trivial application behind CloudFront and API Gateway, redacted logging, and the alarms. The lab guide carries the full Terraform and the attack simulation.
week-13-waf-shield-protection/
|
+-- terraform/
| +-- environments/dev/ HCP backend, OIDC, both provider aliases
| +-- modules/app/ API Gateway REST API, Lambda, CloudFront
| +-- modules/waf-edge/ the CloudFront-scope web ACL
| +-- modules/waf-origin/ the regional web ACL on the REST API stage
|
+-- scripts/ the attack simulation and teardown checks
Shield Standard needs no module, because there is nothing to create. It is already protecting the account:
Validation and Evidence
The firewall is the control, so the test is an attack simulation against both paths — the CloudFront edge and the origin invoke URL.
| Test | Expected | Actual | Status |
|---|---|---|---|
| Benign request, Count mode | Allowed, nothing counted | Allowed | Pass |
| Path scan in Count mode | Counted, not blocked | Counted — visible in sampled requests | Pass |
| Path scan in Block mode | Rejected at the edge | Rejected | Pass |
| Same attack against the origin URL directly | Rejected by the regional ACL | Rejected — the bypass is covered | Pass |
| Credentials kept out of logs | authorization etc. redacted | Redacted at source | Pass |
| Edge alarms fire on blocks | Notification sent | Both edge alarms were inert and looked healthy | Fail — see below |
REDACTED; every other header is logged in full. The redaction is selective and it works.
Security and Cost
Security
The firewall itself is the control, so what follows is what protects the rest of it.
Defence at both scopes. The edge ACL protects CloudFront; the regional ACL protects the API Gateway stage. That pairing exists specifically because an origin URL that stays publicly reachable makes an edge-only firewall decorative.
A break-glass IP set evaluated before the managed rule groups, so a legitimate client caught by a false positive can be let through without disabling a rule for everyone.
Logs are redacted at source. authorization, cookie
and x-api-key are declared as redacted fields, so credentials never reach the
log group rather than being scrubbed afterwards.
Cost
$4.93 measured in Cost Explorer across the four days the two web ACLs existed — not estimated. The route to that number is itself a lesson, in Troubleshooting.
| Component | Monthly |
|---|---|
| 2 web ACLs @ $5 | $10.00 |
| 10 rules @ $1 | $10.00 |
| WCU overage | $0 — 953 of 1,500 used |
| CloudFront, API Gateway, Lambda, logs | ~$0 at demo volume |
| Shield Standard | $0 — always on |
WAF charges are prorated hourly, so a build-test-destroy day costs under a dollar. Do not let a monthly figure narrow the design. Shield Advanced, by contrast, is $3,000/month on a one-year commitment and cannot be prorated away.
The real risk is not the rate — it is forgetting it exists. Two web ACLs charge whether or not a single request arrives, with no usage signal to remind you.
Troubleshooting and Lessons
Both edge alarms were dead and looked healthy
Problem. Two CloudWatch alarms on edge-scope WAF metrics never fired, and
never errored.
Root cause. CloudFront-scope metrics have no Region dimension.
An alarm pointed at a non-existent metric series sits in INSUFFICIENT_DATA or
OK forever.
Resolution. Verify against the live metric list rather than against the
config.
Lesson. A well-formed configuration that plans cleanly can still be
completely inert.
The Anti-DDoS rule group rejected both web ACLs
Problem. validate and plan both passed; only the
apply failed.
Root cause. The provider documents
exempt_uri_regular_expression as optional; AWS requires at least one entry
whenever the challenge action is enabled.
Resolution. Supply one.
Lesson. A provider doc marking a field "Optional" is not a live-tested
fact.
The test script was misreporting its own results
Problem. It read HTTP status as a WAF verdict and called the benign
baseline "blocked as expected".
Root cause. A 403 can come from the application, the API, or the firewall.
An HTTP status is not a WAF verdict.
Resolution. Read CloudWatch metrics or the WAF logs, which say what the
firewall actually did.
Lesson. A test that cannot distinguish who refused the request is not testing
the firewall.
The cost figure was wrong, and the correction is on the record
Problem. This post originally said about $1.40.
Root cause. That was arithmetic from the hourly rate, not a figure read off a
bill.
Resolution. Corrected on 2026-08-30 to $4.93 from Cost
Explorer.
Lesson. A calculation is not a measurement, and the gap
between them was 3.5× here.
Cleanup and Key Takeaways
Destroyed via an HCP API destroy run: 33 resources destroyed, 0 added or changed, and every post-teardown check passed. The verification script does not destroy anything — it checks what survived, and distinguishes three outcomes rather than two: gone, still present, and could not verify.
Two web ACLs bill whether or not a request ever arrives, so an incomplete teardown here is a standing $20/month with no usage signal to announce itself.
Key takeaways
- Shield Standard is already protecting you and there is nothing to deploy. The gap it leaves is layer 7, and that is WAF's job.
- Deploy managed rules in Count mode first. Going straight to Block is what produces the day-one outage that gets WAF disabled permanently.
- Protect the origin as well as the edge. An invoke URL that stays publicly reachable makes an edge-only web ACL trivial to bypass.
- Check the WCU sum before adding a managed group. 1,500 are included; CommonRuleSet alone is 700.
- An HTTP status is not a WAF verdict. Only CloudWatch metrics or the WAF logs tell you what the firewall actually did.
Comments