Hosting a Static Website on Amazon S3
In this project I will be demonstrating step by step how to host a static website on an Amazon S3 bucket. “Static websites enable you to decouple your content repository and front-end interface, giving you greater flexibility in how your content is served. Cost-efficiency is another reason companies migrate to a static site because static files are lightweight and often faster and cheaper to serve.” — Joe Holmes
What is Amazon S3?
“Amazon Simple Storage Service (Amazon S3) is an object storage service that offers industry-leading scalability, data availability, security, and performance. Customers of all sizes and industries can use Amazon S3 to store and protect any amount of data for a range of use cases, such as data lakes, websites, mobile applications, backup and restore, archive, enterprise applications, IoT devices, and big data analytics. Amazon S3 provides management features so that you can optimize, organize, and configure access to your data to meet your specific business, organizational, and compliance requirements” -AWS Documentation
Prerequisites:
- An AWS Account(If you don’t have one, see my “Creating an AWS Account, and Best Practices with IAM Users” project.)
- Familiarity with the AWS Console.
- An HTML file(the static website file).
[Step 1: Log into your Account]
[Step 2: Navigate to S3 and Configure the S3 Bucket]
- Click on “Create Bucket”
- Enter a globally unique name for your bucket.
3. We’ll leave ACLs disabled.
4. We will disable “Block All Public Access” and acknowledge that we want to take that risk, because we want our bucket to be accessible from the internet(but that’s not all, we’ll also have to write a policy which will allow our bucket to be accessible from the internet). We’ll leave everything else as is and scroll all the way to the bottom and create our bucket.
5. Once your bucket is created, click on it and upload your static website(HTML) file.
6. Once that’s done you’ll need to set permissions for your bucket. Click on “permissions” on your bucket menu, remember we already allowed public access on the bucket, now we need to set a “Bucket Policy” which will have the same permissions(allows public access to our S3 bucket).
7. Now we need to enable “Static Website Hosting” on our bucket. Click the “Properties” panel and scroll all the way down to the bottom. Enable Static Website Hosting.
8. Open the link in a new browser tab to see if it works.
WELL DONE ON CREATING YOUR FIRST AMAZON S3 BUCKET AND HOSTING YOUR FIRST STATIC WEBSITE ON IT!!!
[Step 3: The Clean Up]
- Delete the objects in your S3 bucket.
2. Delete the bucket itself.
AND YOU’RE ALL DONE!
I hope you found this project useful.
Until Next Time.