Cloud Hopping: Deploying a Website Using Amazon S3

Introduction

Welcome to our 'Cloud Hopping' series! Today's focus is on how to use Amazon S3 (Simple Storage Service) for hosting static websites. S3 is not only cost-effective and reliable but also perfect for hosting websites with fixed content like HTML, CSS, and JavaScript. Ideal for personal projects and small business sites, S3 simplifies web hosting without the need to manage a server. In this guide, I’ll walk you through creating an S3 bucket, uploading your web files, and making your site live on the cloud. Let’s get started and bring your website to the AWS cloud!

Teal Sand Pail Near Sand Shovel Toy

Walkthrough

Prerequisites

  • First, gather your website files (HTML, CSS, JavaScript, etc.).
  • For this example, I am using a test index.html page that I will provide below.
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Simple Website</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            text-align: center;
            padding: 50px;
            background-color: #f4f4f4;
        }
        h1 {
            color: #333;
        }
    </style>
</head>
<body>
    <h1>Welcome to My Simple Website</h1>
    <p>This is a basic HTML page deployed using Amazon S3.</p>
</body>
</html>

Creating a Bucket on Amazon S3

  • Sign into the AWS Management Console and navigate to the S3 service.
  • Create a new bucket.
  • Give it a unique name (it can't be a name someone else has already used), so consider adding your initials or name to it.
  • Select a region; this is where your bucket and website code will reside. Think of a region as a geographical area, like Ireland or North Virginia. Choose one that's closest to your end-users for better performance. In a later installment, I'll show you how we can use CloudFront to distribute your site globally.
  • Ensure the bucket is publicly accessible by unchecking “Block all public access”.

Uploading Website Files

  • Click on the bucket name to open it.
  • Upload your website files to the bucket. You can drag and drop files or use the upload button.
  • Once uploaded, your files are stored in the S3 bucket.

Enabling Static Website Hosting

  • In the “Properties” panel of the bucket settings, find the option for “Static website hosting”.
  • Enable it and specify index.html as the name of the index document..
  • Save the changes. AWS will provide you with a URL for your hosted site.

Setting Permissions

  • To make your website viewable to the public, set the correct bucket permissions.
  • Create a bucket policy that allows public read access. You can use the policy generator provided by AWS or write a custom policy.
  • Here is an example policy:
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::YOUR-BUCKET-NAME/*"
        }
    ]
}
  • (Replace YOUR-BUCKET-NAME with your actual bucket name.)
  • Be careful with public access permissions to ensure you're only sharing intended content.

Testing Your Website

  • Open the provided URL in a web browser.
  • Check if the website loads correctly and all links and resources are functioning. If so, congratulations, you now have a self-hosted website!
  • If you encounter issues, double-check your bucket permissions and file names.

Conclusion

And that's a wrap on how to deploy a website using Amazon S3! You've just taken a significant step into the world of cloud computing by successfully hosting your website on one of the most reliable and cost-effective platforms available. Amazon S3 offers a straightforward solution for hosting static content, making it an ideal choice for beginners and professionals alike who are looking to leverage the power of the cloud with minimal complexity.

Looking Ahead: Route 53 and CloudFront

But our journey into AWS doesn't end here. In upcoming articles of the 'Cloud Hopping' series, we'll explore how to enhance your website's functionality and performance using other AWS services like Route 53 and CloudFront.

Telescope in Front of Body of Water

  • Route 53: Amazon's scalable DNS web service. Integrating Route 53 will allow us to configure a custom domain for our S3-hosted website, adding a professional touch and making it more accessible to our audience.

  • CloudFront: AWS's content delivery network (CDN) service. By using CloudFront, we can distribute our content globally, reduce loading times, and improve the overall user experience for visitors no matter where they are in the world.

The combination of S3 with Route 53 and CloudFront not only elevates the professionalism of your website but also optimizes its performance on a global scale. Stay tuned for these exciting topics where we'll delve deeper into the vast capabilities of AWS, helping you to build more robust, scalable, and efficient web solutions.

Thank you for joining me on this journey, and I can't wait to explore more AWS features with you. As always, your feedback and suggestions are highly valued, so feel free to share your thoughts!

S3HOSTINGAWSWALKTHROUGHGUIDE
Avatar for Callum Dennis

Written by Callum Dennis

Loading

Fetching comments

Hey! 👋

Got something to say?

or to leave a comment.