AWS Builder Center

Deploying a Modern Fullstack Web App on AWS Free Tier: S3 + CloudFront vs. EC2

A practical guide comparing static hosting via Amazon S3 and CloudFront against dedicated EC2 instances for student and portfolio web applications.

When deploying a personal portfolio, hackathon project, or student utility web app, choosing the right hosting architecture on AWS can save time, prevent unexpected bills, and provide high availability.
Developers often default to provisioning an EC2 instance because it mirrors local development ( localhost ), but serverless hosting patterns often deliver better performance at a fraction of the operational overhead.



Architecture Comparison: S3 + CloudFront vs. EC2

Option A: Amazon S3 + Amazon CloudFront (Serverless Static Hosting)

  • How it works: You upload production build artifacts (HTML, CSS, JS bundles) directly into an S3 bucket configured for static hosting, fronted by AWS CloudFront CDN for edge caching and SSL termination.
  • Cost: Practically $0 within AWS Free Tier limits (5 GB S3 standard storage and 1 TB CloudFront data transfer out per month).
  • Maintenance: Zero server patching, no OS updates, and automatic global scale.
  • Best suited for: Single Page Applications (React, Vue, Vite builds) connecting to external APIs.

Option B: Amazon EC2 ( t2.micro  /  t3.micro )

  • How it works: A full virtual Ubuntu/Linux server running Node.js, Nginx, and process managers like PM2.
  • Cost: 750 free hours per month for the first 12 months (enough to keep one instance running continuously).
  • Maintenance: Requires manual security group configuration, SSH key management, Linux patches, and reverse proxy setup.
  • Best suited for: Monolithic apps requiring continuous background jobs or direct server-rendered runtimes without decoupled APIs.



Step-by-Step: Setting Up Static Web Hosting on S3 + CloudFront

1. Build and Configure Your S3 Bucket

  1. Build your frontend application locally ( npm run build ).
  1. Open the Amazon S3 Console and click Create bucket.
  1. Choose your nearest AWS region (e.g.,  ap-south-1  for Mumbai).
  1. Uncheck Block all public access (acknowledge the warning) and create the bucket.
  1. In Properties, scroll to the bottom and enable Static website hosting. Set your index document to  index.html .
  1. Add the following read-only bucket policy under the Permissions tab:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::YOUR-BUCKET-NAME/*"
}
]
}
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article