I am wondering if many people have ever gone down the route of creating complex dynamic websites on S3. I'm scoping out options for a quick way to bang out a POC and I'm not particularly seeing any reason for going down the traditional webserver route when I feel as though I can properly leverage my own skills by busting out the backend purely running on AWS/ApiGateway/Lambda and interacting with a Js/React/S3 frontend.
Firstly I am wondering if deploying anything beyond a basic static site on S3 is a fools endeavour from the context of any webdev jockeys around here.
Secondly if not - is there any front end tooling that is specifically designed around this area?
Apologies if a dumb question.
If you need server side compute, lambda and API GW is the way to go.
You can follow a tutorial like this one: https://www.newline.co/fullstack-react/articles/deploying-a-...
- Use CloudFront in front of your S3 bucket, in this way you get custom domains and HTTPS and decrease requests (and its associated costs) to the S3 origin. Don't bother with S3 website hosting, unless you're using another CDN to front the website. Even then, I'd rather use CDN -> CloudFront -> S3 just to prevent setting the bucket as public and leverage some behaviors (see below)
- On CloudFront, remember to set a default root object (this is the index.html file)
- If you are using a router on your SPA, set CloudFront to handle 403 and 404 errors as custom responses - return 200 with the path set as your /index.html
- Getting 403 on CloudFront? Check your bucket policy first!
- Page not updating? Remember to invalidate the cache after updating the files in the bucket.
- Want to avoid CORS shenanigans? You can add your API Gateway endpoint as an custom origin with no caching on the same distribution but on another path.
Admittedly, it has been a few years since I last tried this, perhaps things have improved or there is better tooling out there.
Edit: if you don’t want to manage a server then you can use Next.js and Vercel and get same benefits as server rendered pages. So that’s an option too.
Using Next.js on Cloudflare and Cloudflare Workers (edge-functions) or deno is a basically as free and serverless as it gets. Cloudflare pages are free.
Here's an article on it: https://engineering.udacity.com/hosting-next-js-at-the-edge-...
Then there is: https://remix.run/