Hosting a static website on AWS is an affordable and scalable solution. This guide will walk you through registering a domain with Route 53, configuring an S3 bucket for website hosting, setting up public access, and routing your domain to your S3 bucket using Route 53.
Step 1: Register and Pay for a Domain via Route 53
Navigate to the AWS Route 53 Console.
Click on Domains > Register Domain.
Search for your desired domain name and check availability.
Once selected, proceed to checkout and pay for the domain.
After purchase, AWS will automatically create a Hosted Zone for your domain.
Step 2: Create and Configure Your S3 Bucket
Go to the S3 Console and click Create Bucket.
Name your bucket exactly the same name as your domain name (e.g.,
example.com
).Choose a region and remember it (you will need it later).
Uncheck Block all public access to allow your website to be publicly accessible.
Click Create Bucket.
Step 3: Update the Bucket Policy for Public Access
To make your website publicly accessible, you need to add a bucket policy. Navigate to Permissions in your bucket and insert the following policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::Bucket-Name/*"
]
}
]
}
Replace YOURWEBSITENAME.COM
with your actual bucket name.
Step 4: Enable Static Website Hosting
In the Properties tab of your S3 bucket, scroll down to Static Website Hosting.
Select Enable.
Set the Index document as
index.html
.Note the Bucket website endpoint provided, as it will be needed later.
Step 5: Upload Your Website Files
Click on Objects in your S3 bucket.
Click Upload and select your
index.html
file.Once uploaded, your website is now accessible via the bucket website endpoint.
Step 6: Configure Route 53 to Point to Your S3 Bucket
Open Route 53 Console and navigate to Hosted Zones.
Click on your domain name.
Click Create Record.
Choose Simple Routing.
Enable Alias.
In the Alias Target, select S3 website endpoint.
Choose the region where your bucket is located.
Select your S3 bucket from the list.
Click Create Record.
Step 7: Verify Your Setup
Open a web browser and enter your domain name.
Your static website should now be displayed.
If not, double-check your bucket name, permissions, and Route 53 settings.
Conclusion
Congratulations! You have successfully hosted a static website on AWS using S3 and Route 53. This method provides a cost-effective and scalable solution for hosting simple websites. Thanks for following along!