You can use services such as Netlify or Vercel to generate and deploy you static site. These services leverage AWS architecture or equivalents such as GCP or Azure to deploy your site on the CDN.
Netlify Free tier: Netlify provides 300 free build minutes per month.
AWS CloudBuild Free tier: AWS CodeBuild provides 100 free build minutes. So, 300 minutes will cost you 300-100(free minutes) = 200. 200 min × $0.005/min = $1 Other things to factor in 1. S3: 0.025$/GB - One static site will typically be around 100MB 2. DNS: 0.5$ per domain (Avoidable if you buy your domain on GoDaddy and use their built in DNS service.) 3. CodePipeline: 0.5$ per code pipeline 4. Free tier of AWS CloudFront. (Free tier for a year, after which it adds upto less than 5$ a month.) To deploy site per month it costs - $2.025
The bet on AWS pays off if you have high loads and greater than 1 concurrent builds. Netlify allows 3 concurrent builds on the $19 plan. On AWS the same costs around $2.025 + 2 more Code pipelines at 0.5$ each. Total at 3.025$
The only disadvantage of using AWS is the need for intricate techinical knowledge on how to deploy your code. Netlify uses your
package.json data commands to build and configure your site.
Setup your code on git and commit all of it. Use any of Github, Butbucket or Gitlab to maintain your code.
AWS CodePipeline is a tool that looks for commits and pulls made to a git repository and triggers an action on the code. Action may be postprocessing of data, building container images, exporting static files and so on.
Add the build command to
package.json file of your NextJS project. This command will help us build and export the project.
next export generates a pre-rendered HTML export into a folder named
... build: next build && next export ...
Click on next
One you choose your source, AWS will ask you to connect your repo to the pipeline. Provide all necessary permissions. Click Next.
Use the Create Project button
Image registry: Other registry Custom Docker image registry URL: registry.hub.docker.com/library/node:alpine Previleged: True
Choose the Insert custom build command option and enter the
npm run build .
Choose any of your S3 buckets
Check the Extract file before deploy option
Click on the pipeline you just created and view its history. If the trigger has been setup correctly, here's what you'll see.