AWS WAF AI Traffic Monetization with Amazon CloudFront

AWS WAF → Amazon CloudFront → Amazon S3

Deploy AWS WAF AI traffic monetization with Amazon CloudFront to automatically charge AI bots for content access using the x402 payment protocol.

This pattern deploys an Amazon CloudFront distribution protected by an AWS WAF WebACL configured with Bot Control and AI traffic monetization.
When AI bots (crawlers, scrapers, LLM training agents) request content, AWS WAF classifies them using Bot Control's machine learning and returns an HTTP 402 Payment Required response with a price manifest.
Bots that complete payment via the x402 protocol (USDC on Base or Solana) are granted access. Bots that don't pay are blocked.
The pattern deploys in TEST mode using Base Sepolia testnet — no real money is involved until you switch to production mode.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/waf-cloudfront-ai-monetization-cdk

Deploy

<code>cdk bootstrap</code><code>npm install</code><code>cdk deploy</code>


Testing

See the README for detailed testing instructions.

Cleanup

cdk destroy
Note: The Amazon S3 bucket has a DESTROY removal policy and will be deleted automatically with all objects.

Created by:

Nithin Chandran R

Nithin Chandran R

Technical Account Manager at AWS

Follow on LinkedIn