AWS S3 ποΈSimplified: CloudβοΈ Storage Made Easyπ οΈ
Day 3 : β‘ Explore features, use cases, and practical demo on cloud storage π€ S3
In this article, I will be discussing one of the most popular and commonly used AWS servicesβor perhaps the very first service that many of us encounter when starting our AWS journey (though not in my case).
This article covers the fundamentals of S3 Buckets ποΈ, key terms related to the service π, and well-documented steps with clear explanations π. You'll learn about the essential terms you'll encounter while creating an S3 bucket and hosting a static website π. Plus, a practical video π₯ will walk you through this simple project, making it easy to follow along!
What is an S3 Bucket?
It solves the problem of storage
An S3 bucket is a virtual container in AWS S3 (Amazon Simple Storage Service) where you can store your data, such as files, images, videos, or any other objects. Think of it as a folder in the cloud, but with powerful capabilities for storage, organization, and accessibility.
How Amazon S3 works ?
Amazon S3 is an object storage service that stores data as objects within buckets. An object is a file and any metadata that describes the file. A bucket is a container for objects.
To store your data in Amazon S3, you first create a bucket and specify a bucket name and AWS Region. Then, you upload your data to that bucket as objects in Amazon S3. Each object has a key (or key name), which is the unique identifier for the object within the bucket.
We can use S3 Bucket to store any static content but as a DevOps Engineer, S3 Buckets are used to store backups and logs etc
Storage for an bucket is unlimited but an object size cannot be more than 5TB (if this size limit exceeds then the object can be stored using multipart uploads)
Some Key Topics related to S3 Bucket
These are according to AWS Official Documentation
1. Buckets ποΈ
Buckets are like storage containers in Amazon S3, where you store all your data (files).
You can have up to 10,000 buckets by default, and each one must have a unique name.
Each bucket resides in a specific AWS region π.
2. Objects π
Objects are the files (images, documents, videos, etc.) stored inside a bucket.
They consist of data and metadata (information about the file).
Every object has a unique key (file name) to identify it.
3. Keys π
An object key is the unique identifier for a file within a bucket.
The key is part of the URL used to access the object, e.g., photos/puppy.jpg.
4. S3 Versioning π
With S3 Versioning, you can keep multiple versions of the same object in one bucket.
This helps restore previous versions in case of accidental changes or deletions.
5. Version ID π
When you enable S3 Versioning, Amazon S3 assigns a unique version ID to every object.
Older objects that existed before versioning have a null version ID.
6. Bucket Policy π
A bucket policy is a set of rules that control who can access the bucket and its objects.
You can define permissions for different users or actions, like allowing access from a specific IP address or granting cross-account permissions.
7. S3 Access Points π
S3 Access Points are like custom access endpoints to manage how data is accessed in a bucket.
Each access point has its own policy to control access.
8. Access Control Lists (ACLs) π
ACLs are used to grant specific permissions for individual objects or buckets.
They let you control who can read or write to a file but are less commonly used today in favor of policies.
9. Regions π
You can choose the AWS region where your S3 bucket will be located.
Choosing a region can help reduce latency, lower costs, or meet regulatory requirements.
Objects stored in a region stay within that region unless transferred.
π‘Object Lock, S3 Replication, S3 Object Ownership, Block Public Access, Bucket Versioning, Server Access Logging, Storage Classes : All these terms have been properly explained in the video thatβs why I am not including its explanation here
Practical Implementation
Lets start with process of hosting a simple static website on the bucket
π₯ After watching the video, follow these steps to implement the process at your own pace. In my video, I'll also share some extra insights π‘ that might not be included in these steps. These additional points will give you a deeper understanding and enhance your learning! π
π That's exactly why I started providing videos β so I can share those extra nuggets of information π€ to make the process even clearer and more engaging for you all! π
Step 1: Sign in to AWS Console
What to do: Go to the AWS Management Console and log in with your credentials.
Reason: You need access to AWS services, including S3, to create and manage your bucket.
Step 2: Create a New S3 Bucket ποΈ
What to do:
Navigate to S3 under Services.
Click on Create bucket.
Choose a unique bucket name (e.g.,
my-static-website-bucket
).Select an AWS Region (e.g., US-East-1) that is closest to your users for low latency β‘.
Leave other options as default for now and click Create.
Reason:
The bucket name is unique globally, ensuring that no other AWS user has the same name.
The Region helps you decide where your data will be stored physically π.
NOTE : Although S3 is a Global Service but it requires a region to store your data
Step 3: Upload Your Website Files π
What to do:
Inside your newly created bucket, click Upload.
Select your website files (
index.html
,style.css
, etc.).Click Upload to store these files in the bucket.
Reason:
You need to upload your website files (like HTML, CSS, and images) to the bucket in order for them to be served to users.
index.html is the main file that browsers look for when accessing the website.
Step 4: Enable Static Website Hosting π₯οΈ
What to do:
Go to the Properties tab of your S3 bucket.
Scroll down to Static website hosting.
Enable it by clicking on Enable.
In Index document, enter
index.html
.Optionally, set an Error document (e.g.,
error.html
).Click Save changes.
Reason:
By enabling Static website hosting, youβre configuring the bucket to act as a web server π₯οΈ for your site.
The index.html file will be the default page when users visit your website.
Step 5: Set Bucket Permissions π
What to do:
Go to the Permissions tab.
Under Block Public Access, click Edit and uncheck Block all public access.
Confirm by typing "yes" and click Save changes.
This step allows public access to your website files.
Reason:
- By default, AWS restricts public access to your S3 bucket for security. For a static website, you need to make the bucket publicly accessible so users can visit your site π.
Step 6: Set Bucket Policy for Public Access π
What to do:
Under the Permissions tab, go to Bucket Policy.
Add the following policy to allow public read access to the files:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-static-website-bucket/*"
}
]
}
Replace
my-static-website-bucket
with your actual bucket name.Click Save.
Reason:
The Bucket Policy specifies who can access the contents of the bucket.
The s3:GetObject action allows everyone (Principal
"*"
) to read (get) the files in your bucket.
Step 7: Access Your Website π
What to do:
Go to the Properties tab of the bucket and find the Static website hosting section.
Youβll see a URL like:
http://my-static-website-bucket.s3-website-us-east-1.amazonaws.com
Click on the URL to open your website in a browser.
Reason:
The URL provided by AWS is the address where your static website is now hosted.
You can share this URL with others to let them access your site π.
Conclusion
π― Bonus Tip: Reducing Costs in S3 π°
Looking to cut down on your S3 storage costs? Hereβs a simple trick! π If youβre storing static content in your S3 bucket, you can reduce costs by moving less frequently accessed files to a lower-cost storage class. ποΈπΎ
For example:
Files that are rarely accessed or where access time isnβt critical can be shifted to S3 Standard-IA (Infrequent Access) π or S3 Glacier π₯Ά for archival purposes.
By leveraging these storage classes, you only pay for what you need while keeping your content accessible when required! πΌ
Thank you for following along on this AWS S3 journey! π I hope you found this tutorial helpful in understanding the fundamentals and practical steps of hosting a static website on S3. π
π Subscribe to my newsletter to stay updated with more exciting tutorials and tips on AWS and cloud computing! β¨
π¬ Send me your feedback β I'd love to hear your thoughts, suggestions, or questions. Let's grow and learn together! π
π Credits: This blog is enriched with insights from the AWS Official Documentation.
Happy Cloud Building! βοΈπ§