I read about attacks that resulted in exorbitant billing, something that couldn’t happen when I used a commercial server-based hosting company (hosting.com). I’m set up for a notification when my monthly billing reaches a limit, but the DDoS attack could occur when I’m sleeping or on vacation, when I can’t respond right away to the notification.
Unless you have specific requirements such as setting access permissions on a per-object basis, check out Cloudflare R2. It uses the S3 API and behaves almost identically but there are no egress fees and you can keep it behind Cloudflare’s proxy. I recently moved our statically hosted product there and it’s been rock solid.
Just to tack on here, the reason to use cloud front is because it supports AWS shield which is their service to provide ddos protection. Also, adding a waf on the cloud front with rate limiting can further mitigate cost based attacks.
Personally, I’m not sure why they still make static public web hosting even an option, when CF is 100% superior, and doesn’t take that much additional configuration.
I do use CloudFront and I do have a billing alert. My concern is that isn’t enough. Below someone suggested a lambda to shut it down, but I’m not sure I want to add even more complexity. I’m not sure how do sufficient testing.
The new flat-rate pricing in Cloudfront has a free option for hobbyists and beginners that even included DDoS protection and 5x WAF rules.
Important to note - you need to implement origin access control to make sure only cloudfront can access your bucket assets. Otherwise CF doesn’t help this problem at all.
Only down side is I can’t seem to see how to implement flat-rate pricing in the python CDK yet. It was only announced 3 week ago, so probably not yet available in IaC.
I don’t like the idea of enabling features and adding code to implement security. Complexity creates opportunities for system failure.
I mean, the obvious solution then is to shut down your website! You can’t have code failure if you have no code!
I joke, obviously. In seriousness, the lambda with billing alert is an option, but it’s overkill for this purpose. Look into Cloudfront’s new flat-rate pricing (announced earlier this month). There’s a free option, no overage fees, built-in security options, and you don’t pay for traffic from attacks.
As you’ve discovered, AWS in general is often not ideal for preventing denial-of-wallet attacks. Research into solving this exact problem for my own site on AWS was how I discovered CloudFlare’s offerings in the first place.