Home› Blog› Week 13 - AWS WAF + Shield Standard: The DDoS Prot…
AWS Weekly Lab AWS Terraform

The DDoS protection you already have, and the layer it cannot see

AWS Shield Standard is free, always on, and has no Terraform resource. It also cannot read a single line of HTTP. This week builds the layer that can — two AWS WAF web ACLs across two scopes, deployed in Count mode first, then flipped to Block with the evidence to justify it.

Verified against current vendor documentation on 22 August 2026. Pricing, limits and API behaviour were checked against the official docs on that date. Cloud services change fast — if you are reading this much later, treat the specifics as a starting point and re-check the linked sources.
AWS Platform Engineering Lab · Week 13 of 52

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.

DifficultyAdvanced
Lab runtimeFour days before teardown
Measured cost$4.93 — and the correction behind that number is in Troubleshooting
DeploymentTerraform via HCP Terraform with OIDC
Full lab guideGitHub — prerequisites, Terraform, commands, validation, cleanup

Cloud Services and Concepts

ServicePurpose hereWhat it is
AWS Shield StandardLayer 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 WAFThe 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 CloudFrontThe 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 APIThe 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 + SNSBlocked-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

Normal user via the CloudFront URL Origin URL holder skips the edge aws AWS Cloud Region: us-east-1 1 CloudFront the edge Edge web ACL CLOUDFRONT scope 2 API Gateway REST, not HTTP Origin web ACL REGIONAL scope echo answers if it got through 3 Shield Standard L3/L4, always on, nothing to deploy CloudWatch Blocked + Counted SNS email alert The same five rules sit at both scopes, so knowing the origin URL buys nothing — which is the only way the edge is worth deploying.
Two web ACLs, the same five rules. The bypass meets the second one.
  1. Shield Standard absorbs layer 3/4 volumetric attacks at the AWS edge, always, with nothing configured.
  2. A request reaches CloudFront, where the edge web ACL evaluates it.
  3. 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.
  4. Managed rule groups run — in Count mode first, Block mode only once the sampled requests show what they would have rejected.
  5. Allowed requests reach the API Gateway REST API, where a second, regional web ACL evaluates them again.
  6. 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

RequirementDetail
AWS accountPermission for WAFv2, CloudFront, API Gateway, Lambda, CloudWatch, SNS
Terraform>= 1.10. Note the provider gap in Troubleshooting
HCP TerraformWorkspace with OIDC to AWS. No static keys
RegionsEdge 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
Only the directories that matter. The full repository is on GitHub.

Shield Standard needs no module, because there is nothing to create. It is already protecting the account:

AWS Shield console showing Shield Advanced setup incomplete and the L7AM migration banner
Shield Standard is already protecting this account. Shield Advanced is unsubscribed — and the banner states the L7AM sunset dates.

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.

TestExpectedActualStatus
Benign request, Count modeAllowed, nothing countedAllowedPass
Path scan in Count modeCounted, not blockedCounted — visible in sampled requestsPass
Path scan in Block modeRejected at the edgeRejectedPass
Same attack against the origin URL directlyRejected by the regional ACLRejected — the bypass is coveredPass
Credentials kept out of logsauthorization etc. redactedRedacted at sourcePass
Edge alarms fire on blocksNotification sentBoth edge alarms were inert and looked healthyFail — see below
Side-by-side terminal output of the attack simulation in Count mode and Block mode
Left: Count mode, everything 200. Right: Block mode, every attack 403 — and the benign baseline still 200.
WAF log record showing Authorization, Cookie and X-Api-Key all REDACTED while other headers remain
All three credential headers come back REDACTED; every other header is logged in full. The redaction is selective and it works.
SNS email showing the CloudWatch alarm entering ALARM state
Detection: WAF block → metric → alarm → SNS → inbox.

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.

ComponentMonthly
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.

References

Comments

How was your experience?
Your feedback helps improve this site.
PoorExcellent