Does AWS WAF charge for requests that come from IP addresses that are blocked?

If an ip address exceeds its rate limit and a WAF rule blocks it for a period of time, do the future requests from that ip address still get charged to me by the WAF service?

(And if so, why it beneficial to even use a WAF service if I am charged for unauthorized requests with or without it? - Either by WAF or by Lambda. Especially since WAF costs 3 times as much as Lambda for requests. Maybe I could just put my rate limiting logic in the lambda function and save money.)

Note: My plan is to use: WAF → API Gateway → Lambda

I thought you pay by rules?

That would make sense, but this is what is says:

https://aws.amazon.com/waf/pricing/

Resource Type Price
Web ACL $5.00 per month (prorated hourly)
Request $0.60 per 1 million requests
Rule $1.00 per month (prorated hourly)

pricing is per WAF, per rule and per request

my guess is that you do get billed for blocked IPs because it has to consume the request first and do the lookup to know to block

https://aws.amazon.com/waf/pricing/

I guess what I’m wondering, is why I (or anyone) should bother blocking them if their requests will cost me anyway. Letting them into a small lambda function will only cost $0.20/million which is a third of the cost of blocking with with WAF.

You have to pay for memory/CPU also with a lambda function? If you have API Gateway in from that would have cost even more. WAF is cheaper, faster and fit for purpose. If you use it with Cloudfront there’s a discount bundle to get WAF almost for free.

Other issues with lambda:

  • You can quickly reach your capacity limit by a bot and not have lambda to serve
  • The cost is not just the request and then memory/CPU but also logs, metrics and anything else you have with the lambda
  • How do you block with lambda if it’s stateless? E.g. 100 requests / minute. How do you keep track? If you need a cache or some storage that increases the cost further and also the complexity.

Because lambda has ridiculously low throttling values for concurrent requests.

WAF will scale and mitigate a high volume / well coordinated DDOS / call flood. Having that reach your backend would be catastrophic and you will almost immediate see degradation / outages.

Move to Cloudflare. Had massive DDOS attacks from Russia and China and it cost me $3700/month in WAF rule requests for a $1600 infrastructure. Moved to cloudflare and even paid the $200/mo. WAF rule costs dropped back to zero.

Those countries are blocked to access our website already. Nothing good coming from there.

Aws WAF is useful in conjunction with cloudflare to restrict origin access so you can’t bypass the cloudflare WAF :ok_hand: