![[Edge Security Defense] Detect, Deceive, Monetize: Handling AI Bots and Scrapers with AWS WAF and Amazon CloudFront](https://prod-assets.cosmic.aws.dev/a/3MgACAAHTw3yydpSexd1wSENupY/cove.webp)
[Edge Security Defense] Detect, Deceive, Monetize: Handling AI Bots and Scrapers with AWS WAF and Amazon CloudFront
Block unwanted AI agents and stop AI scraping without disappearing from AI search. Use the AWS WAF Security analytics and AI Traffic Analysis dashboards to tell normal human traffic apart from AI crawlers, bots, and attack traffic. Feed web scrapers decoy data with a CloudFront Function, and charge AI agents per request with the AWS WAF Monetize action. Edge-native defense for AI agents, bots, and attacks.
📌 Empowering Business: Cloud Network & Edge Services📌 🎯 Subject Matter Expert: WAF & Route 53 🎯
Know Your Traffic, Own Your Edge 🛡️
Over the years the deal was simple. You publish, search engines crawl, and people click through to your site. The AI era is rewriting that deal. People ask an assistant and read the answer. Agents browse, compare, and buy for them.
- 🤖 Machines are now the majority. Industry reports suggest automated traffic has passed human traffic on the web for the first time.
- 🔍 Search is turning into answers. Gartner predicted a 25% drop in traditional search volume by 2026. Pew Research Center found clicks fall from 15% to 8% when an AI summary appears, and only 1% click a link inside it.
- ⚖️ Crawling goes up, clicks do not come back. A search engine sends a visitor back every few pages it crawls. AI platforms can crawl thousands of pages per visitor, mostly to train models. You still pay for every request: bandwidth, compute, and origin load.
🤔 So what do you do?
🚫 Block every AI bot, and you vanish from the AI answers your customers read.
✅ Allow every AI bot, and your costs climb while your data trains someone else's product.
The same question applies to every visitor at your edge: humans, good bots, scrapers, attackers, and API clients. Each one deserves a different response.
This post shows a third way with AWS WAF and Amazon CloudFront: detect who is hitting you, deceive the traffic you do not want to tip off, and monetize the clients that keep coming back. Consider an example e-commerce scenario.
🔥 Sound Familiar?
Monday morning. Your origin bill is up, but sales are flat. 📈📉 Marketing says conversion rates "look weird". A competitor matched your weekend price drop within the hour. You open the logs and see Chrome user agents everywhere, from hundreds of IPs. You add a rate-based rule. The scraper rotates IPs. You block a user agent. It switches to Firefox. 😤
🎯 Three Moves, One Web ACL

⚡ Edge-native · 🏷️ Label-driven · 🚫 No new servers · 🧪 Count and
TEST mode first🔍 Step 1: Detect
📊 Security Analytics Dashboard
In the AWS WAF console, choose Security analytics. It shows request logs from every web ACL and Region in one view, free, and on by default for CloudFront.

😎 The cool parts
- Click to filter: every bar has Show only and Exclude, so one click pivots the whole dashboard.
- Group by: split the Requests chart by rule, label, country, or JA4 to see when a bot kicked in.
- Labels panel: ranks Bot Control labels next to your own, so you measure every rule.
- Path share %: shows which pages bots want most.
- JA4 next to Client IP: many IPs with one JA4 means one scraping tool. Plus 10+ more dimensions to slice by.
🤖 AI Traffic Analysis Dashboard
Under your web ACL → Traffic overview → AI Traffic Analysis, you see each AI bot by name and organization, its intent (training, search, assistant), its top URLs, and 14 days of trends.

🤖 Bots Dashboard in Traffic Overview
Open your web ACL → Traffic overview → Bots. These near real-time charts come from the CloudWatch metrics AWS WAF collects as it checks each request.

🎭 Step 2: Deceive
Blocking tells a scraper it was caught, so it adapts. Instead, let it in and give it wrong data. We use bot scrapers as the example here, but the same pattern works for any traffic you can label, such as credential stuffers, fake sign-ups, or inventory hoarders.
① Tag, don't block. A rule matches scraper labels on
/products , skips bot:verified , and uses Count with a custom header bot: true . AWS WAF sends it on as x-amzn-waf-bot .💡 Tip: The scraper labels used here come from the Bot Control Targeted protection level, which has its own pricing. Start with Common to see verified bots, then enable Targeted where scraping hurts most.
② Swap at the edge. A CloudFront Function on viewer request rewrites the URI:
function handler(event) { var request = event.request; var headers = request.headers;
// AWS WAF tagged this request as a scraper if (headers['x-amzn-waf-bot']) { // Serve the shadow catalog page if (request.uri === '/products.html') { request.uri = '/products-shadow.html'; } // Serve the shadow catalog data if (request.uri === '/products.json') { request.uri = '/products-shadow.json'; } } return request;}The rewrite happens before the cache lookup, so humans never get a cached decoy.
③ Make it believable. The decoy file looks just like the real one. Only the values that matter to a scraper change, such as prices or stock.
📝 Note: Keep the decoy page as a replica of the real page, so the scraper sees a normal200 OKand has no reason to suspect anything. Keep verified crawlers out of it, and addnoindexto the shadow pages.
💰 Step 3: Monetize
Not every request needs to be blocked or fooled. Some should pay. Heavy AI crawlers are the obvious example, but the same idea applies to premium APIs, pricing feeds, market data, or any content worth paying for. AWS WAF AI traffic monetization uses HTTP 402 (Payment Required) and the open x402 protocol to charge per request, at no extra charge beyond standard AWS WAF pricing.
① Set a price with a
MonetizationConfig on the web ACL, in TEST mode first (for example 0.001 USDC per request on Base Sepolia).② Flag heavy users. In this example, a rate-based rule scoped to
bot:category:ai adds the label ai:high-volume when a client passes your fair-use limit:{ "Name": "Flag-HighVolume-AI-Bots", "Statement": { "RateBasedStatement": { "Limit": 300, "EvaluationWindowSec": 300, "AggregateKeyType": "IP", "ScopeDownStatement": { "LabelMatchStatement": { "Scope": "LABEL", "Key": "awswaf:managed:aws:bot-control:bot:category:ai" } } } }, "Action": { "Count": {} }, "RuleLabels": [{ "Name": "ai:high-volume" }]}💡 Tip: To monetize a premium API instead, scope the rule to a path such as/api/premium/*rather than the AI bot label. Scrapers rotate IPs, so consider aggregating on JA4 or a custom key instead of IP.
③ Charge them. A second rule matches
ai:high-volume with the Monetize action. Regular visitors never carry that label, so they never see a 402.🧩 Putting It All Together
One protection pack (web ACL) on one CloudFront distribution runs all three moves for every visitor at your edge: humans, good bots, scrapers, attackers, and API clients. Detection writes labels, and every later rule reads them. You decide what each label means. Here is how it works for bot traffic, the example used in this post:

- Bot Control (Common + Targeted) labels every request.
- Deceive rule tags scrapers on
/productswithx-amzn-waf-bot(Count).
- Rate rule labels heavy users
ai:high-volume(Count).
- Monetize rule returns HTTP 402 to
ai:high-volume.
- CloudFront Function swaps tagged requests to the shadow catalog.
🎤 Conclusion
"Block all" or "allow all" is no longer the only choice. See every visitor, fool the traffic you don't trust, and bill the AI agents and API clients that should pay, all on the CloudFront distribution and AWS WAF protection pack you already run. 🚀
⛽ Fuel Up: Docs That Actually Help
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article