Static Website hosting using Amazon S3


Overview:
Created a simple static website and hosted it on Amazon S3 to learn the basics of cloud computing and how websites can be deployed without traditional web servers. This project helped me understand how to use AWS services like S3 for storing files, setting up public access, and delivering website content directly through the cloud.
Key AWS Services Used:
Amazon S3: Used to store website files (HTML, CSS) and enable static website hosting to serve content directly from the cloud.
S3 Static Website Hosting Feature: Turned on this setting to create a public-facing website using just an S3 bucket.
S3 Bucket Policy: Wrote a custom policy to allow public read-only access, so visitors can view the site in their browsers.
IAM (Identity and Access Management): Explored how to manage user permissions and securely access AWS services.
Steps:
- Create a New S3 Bucket
Begin by navigating to the Amazon S3 service from the AWS Management Console. Select “Create bucket”.
- Set a Globally Unique Bucket Name
Provide a unique name for your bucket. S3 bucket names must be globally unique across all AWS users.
- Adjust Public Access Settings
Since the bucket will be used to host a static website, you’ll need to modify the default access settings.
Untick “Block all public access” to allow public read access to the website content.
Acknowledge the warning to confirm this change.
Keep Default Settings and Create the Bucket
Leave the remaining options at their default values and proceed to create the bucket.Enable Static Website Hosting
Navigate to the newly created bucket.
Go to the “Properties” tab and scroll down to the “Static website hosting” section.
Click “Edit” and enable the feature by selecting “Host a static website”.
- Define Website Configuration
Specify the Index document (e.g.,
index.html
) which acts as the homepage.Optionally, specify an Error document (e.g.,
error.html
) to be displayed for invalid requests.
- Once saved, a public endpoint URL will be generated. This URL can be used to access your website.
- Upload Website Files
In the “Objects” tab, click the “Upload” button.
Add your required files and folders (such as
index.html
,error.html
, CSS or image files).Complete the upload process.
- Apply a Bucket Policy for Public Access
Even though public access is allowed in the bucket settings, you must explicitly grant access by applying a bucket policy.
Navigate to the Permissions tab.
Add a policy that allows
s3:GetObject
permissions for all users (Principal: "*"
) on the bucket resources.
Access Your Static Website
Once the policy is in place, your static website will be publicly accessible using the S3-generated website endpoint.
Learning Outcome:
Gained practical experience in deploying content on AWS infrastructure, managing permissions, and configuring S3 buckets for static site delivery, laying a strong foundation for scalable and cost-effective web hosting solutions in the cloud.
Subscribe to my newsletter
Read articles from Pooja Mehta directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
