AWS Builder Center

Host Your Portfolio Website on AWS Using Amazon S3 and CloudFront in 15 Minutes

Ditch expensive hosting fees. Learn how to deploy a fast, secure, and globally distributed static portfolio website using Amazon S3 and Amazon CloudFront.

Host Your Portfolio Website on AWS Using Amazon S3 and CloudFront in 15 Minutes

As a student developer, having a live portfolio website is crucial for showcasing your projects to recruiters. However, paying monthly hosting fees for a basic static site (HTML, CSS, JavaScript, or a React build) isn't necessary. 
By combining Amazon S3 and Amazon CloudFront, you can host your website in the cloud for fractions of a cent per month, while ensuring it loads instantly anywhere in the world. 

🛠️ The Architecture

  1. Amazon S3 (Simple Storage Service): An object storage service where we will upload our website's static files (HTML, CSS, JS, images).
  1. Amazon CloudFront: A Content Delivery Network (CDN) that caches your site across global edge locations for ultra-fast loading speeds and provides free SSL (HTTPS) protection.

🚀 Step-by-Step Implementation

Step 1: Prepare Your Web Files

Ensure your project folder contains an index.html file as the main entry point. For testing purposes, a basic index.html file with a "Hello World" heading works perfectly. 

Step 2: Create and Configure an S3 Bucket

  1. Open the Amazon S3 Console and click Create bucket.
  1. Bucket name: Enter a globally unique name (e.g., my-student-portfolio-11271).
  1. AWS Region: Choose the region closest to your target audience.
  1. Block Public Access: Keep "Block all public access" turned ON. (We will securely route traffic through CloudFront instead of making the bucket publicly exposed).
  1. Click Create bucket.
  1. Open your new bucket, click Upload, and drag and drop your website files (including index.html). Click Upload to finish.

Step 3: Create a CloudFront Distribution

  1. Open the Amazon CloudFront Console and click Create distribution.
  1. Origin domain: Click the field and select your newly created S3 bucket from the dropdown menu.
  1. Origin access: Select Origin access control settings (OAC). Click Create new OAC, accept the defaults, and click Create. This allows CloudFront to securely read files from your private S3 bucket.
  1. Viewer protocol policy: Scroll down to Default cache behavior and select Redirect HTTP to HTTPS for secure browsing.
  1. Default root object: Scroll down to Settings and type index.html.
  1. Click Create distribution.

Step 4: Update Your S3 Bucket Policy

Once the distribution is created, CloudFront will display a prominent banner at the top of the page saying: "The S3 bucket policy needs to be updated..." 
  1. Click the Copy policy button in that banner.
  1. Go back to your Amazon S3 Console and open your bucket.
  1. Navigate to the Permissions tab, scroll down to Bucket policy, and click Edit.
  1. Paste the copied JSON policy into the editor.
  1. Click Save changes.

🧪 Testing Your Live Website

  1. Return to the CloudFront Console.
  1. Find your distribution and look for the Distribution domain name (it will look like d12345abcdef.cloudfront.net).
  1. Copy the URL and paste it into your browser's address bar.
Your website is now completely live, protected by an SSL certificate, and served through Amazon's global edge network! 

🎯 Conclusion

You have just set up an enterprise-grade web hosting infrastructure for your portfolio. Best of all, because it is built on S3 and CloudFront, it falls entirely under the AWS Free Tier limits for your first year, making it completely free for student experimentation.
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