Skip to main content
AWS WAF cannot call external services. Use Lambda@Edge on viewer request with Include Body.

Coverage

Ask — the function returns 403 on block and forwards everything else, so an ask gate is allowed. Write the rule as Block if you need a hard stop. Use it when you serve AI endpoints through CloudFront and want the control alongside AWS WAF. Not when your prompts exceed the viewer-request body limit. Limits. CloudFront truncates the exposed body silently above that limit — the request does not fail, part of the prompt is evaluated and the rest goes through unseen. Measure your prompt sizes before treating this as a control. Lambda@Edge has no environment variables, so the key must come from Secrets Manager or SSM. Input only, no redaction. Full comparison: Coverage.
  1. Node.js Lambda in us-east-1, deploy as Lambda@Edge.
  2. Viewer request + Include Body (body is not exposed otherwise).
  3. No env vars on Lambda@Edge — load the key from Secrets Manager / SSM at cold start, or bake it at deploy.
  4. CloudFront truncates bodies over the viewer-request size limit.