Back to Blog
AWSS3CloudFrontDevOpsNode.js

Deploying a Full-Stack E-Commerce App on AWS with S3 and CloudFront

How I migrated an e-commerce application from a local dev environment to AWS, using S3 for image storage, CloudFront for CDN, and EC2 for the backend.

S

Sandeep Yadav

April 14, 2026

Deploying a Full-Stack E-Commerce App on AWS with S3 and CloudFront


Deploying a full-stack application to AWS can feel daunting, but with the right approach it's a smooth process. In this post I'll share exactly how I migrated the Jhumkeshwari e-commerce platform to AWS.


Architecture


  • **Frontend**: S3 Static Hosting + CloudFront CDN
  • **Backend**: EC2 (Node.js + Express)
  • **Database**: MongoDB Atlas (cloud-hosted)
  • **Image Storage**: S3 + CloudFront
  • **CI/CD**: AWS Amplify

  • Setting Up S3 for Image Storage


    I replaced local `multer` disk storage with `multer-s3` to stream uploads directly to S3. This eliminated the need to store images on the EC2 instance and made the app stateless.


    const multerS3 = require('multer-s3');

    const s3 = new AWS.S3();


    const upload = multer({

    storage: multerS3({

    s3: s3,

    bucket: process.env.S3_BUCKET_NAME,

    key: (req, file, cb) => {

    cb(null, `products/${Date.now()}-${file.originalname}`);

    }

    })

    });


    CloudFront for CDN


    With CloudFront in front of S3, image delivery is fast globally. I updated all image URLs to use the CloudFront distribution URL instead of direct S3 URLs.


    Lessons Learned


  • Always use IAM roles with least-privilege access for EC2
  • Enable CORS on your S3 bucket if the frontend is on a different domain
  • Use environment variables for all AWS credentials — never hardcode them