Deploying S3 UI Bucket and CloudFront CDN

Deploy React/Vite Frontend to S3 + CloudFront


Step 1 — Create S3 Bucket

  1. Go to AWS Console → S3 → Create bucket.

  2. Bucket name: Give it a unique name (e.g., my-frontend-app-bucket). (This is the only field you change — keep all other settings default.)

    alt text

  3. Leave:

    • AWS Region → Default or your choice
    • Object Ownership → ACLs disabled
    • Block Public Access → Keep as default
    • Versioning, Encryption, Tags → default

alt text

  1. Click Create bucket.

alt text


Step 2 — Create CloudFront Distribution

  1. Go to AWS Console → CloudFront → Create distribution.

alt text

Then enter your Distribution name

alt text

  1. Origin type: Select S3.

alt text

  1. Choose the S3 bucket you just created.

alt text

  1. Keep all other settings default:

alt text

  • Viewer protocol policy → Redirect HTTP to HTTPS
  • Cache settings → Use origin cache headers
  • Logging → Off
  1. Click Next.
  2. Web Application Firewall (WAF): Select Do not enable.

alt text

  1. Click Next.
  2. Review → Click Create distribution.

alt text


Step 3 — Set Default Root Object

  1. Go to your new CloudFront distribution.
  2. Settings → Edit.

alt text

  1. Default root object: index.html

alt text

  1. Save changes.

Step 4 — Build Your Frontend

From your local project:

cd frontend
npm run build

This will generate your build output in dist/ (Vite) or build/ (React).

alt text


Step 5 — Upload to S3

  1. Copy everything inside the dist/ folder (not the folder itself).
  2. Go to S3 bucket → Upload.

alt text

  1. Drag-and-drop files, leave permissions default, click Upload.

Step 6 — Wait for CloudFront Propagation

  • It may take a few minutes for CloudFront to update.

alt text

  • Once done, go to CloudFront → Your Distribution → Copy the Distribution Domain Name (not the ARN).

alt text

  • Paste that into your browser to access your site.

alt text

And that’s it! You’ve successfully set up a serverless frontend with Vite and deployed it to AWS using CloudFront and S3. You can now watch your site update in real-time as you make changes to your code. Happy AWS coding, and thank you so much for doing this workshop until now!