
Amazon S3 Explained: Buckets, Objects, Bucket Policies, ACLs & Static Website Hosting with Real-World Examples
Learn Amazon S3 from scratch with simple real-world examples. Understand buckets, objects, bucket policies, ACLs, public access, and static website hosting. Explore how S3 permissions work and how to securely control who can access your files.
Amazon S3 Explained: Understanding Buckets, Objects, Permissions and Static Website Hosting
1. What is Amazon S3?
Amazon S3 stands for Amazon Simple Storage Service. It is an object storage service provided by Amazon Web Services (AWS).
It allows us to store and retrieve different types of data, such as images, videos, documents, PDFs, application files, backups and website files.
Think about a school where every student has a separate storage locker. Students can keep their books, notebooks, photographs and other belongings inside their lockers.
Amazon S3 works in a similar way:
- The storage locker represents an S3 bucket.
- The items stored inside the locker represent S3 objects.
- The rules controlling who can open the locker represent bucket policies.
- The permissions given to individual people represent access permissions.
In simple words, Amazon S3 is a cloud storage service that allows us to store and access data over the internet.
2. What is an S3 Bucket?
An S3 bucket is a container used to store objects in Amazon S3.
Let's take a real-life example.
Imagine that Arun is a student. He wants to store his college notes, project reports, photographs and videos in a secure place.
He buys a large storage locker and keeps all his belongings inside it.
Similarly, when we create an S3 bucket, we get a storage container in which we can upload our files.
For example, Arun creates a bucket named:
arun-college-storage Inside this bucket, he uploads:
-
notes.pdf
-
project.docx
-
profile.jpg
-
presentation.pptx
-
college-video.mp4
All these files are stored inside the same bucket.
Important points about S3 buckets:
- A bucket is a container for storing objects.
- Every bucket has a globally unique name within its AWS partition.
- We select an AWS Region when creating a bucket.
- We can control access permissions using different AWS security mechanisms.
- A bucket can contain a very large number of objects.
3. What are S3 Objects?
In Amazon S3, the files stored inside a bucket are called objects.
An object generally consists of three important components:
- Data: The actual content of the file, such as an image, PDF or video.
- Key: The unique name used to identify an object within a bucket.
- Metadata: Information about the object, such as its content type, size and last-modified details.
Let's continue our example.
Arun uploads a photograph named
profile.jpg into his S3 bucket.Here:
- Bucket name:
arun-college-storage
- Object key:
profile.jpg
- Object data: The actual photograph.
- Metadata: Details such as image content type and file size.
Now imagine Arun uploads another file inside a prefix called
documents .Its object key could be:
documents/semester-notes.pdf Remember: S3 uses object keys and prefixes. The folders we see in the AWS console are generally a way of organizing and displaying objects, rather than traditional folders in a normal file system.
4. What is a Bucket Policy?
A bucket policy is a JSON-based permission document used to control access to an S3 bucket and its objects.
Let's understand this with a real-life example.
Arun has a storage locker in his college. He keeps all his personal documents inside it.
His friend Bala asks Arun:
"Can I see your project report?"
Arun agrees, but he does not want Bala to access all his personal files.
Now imagine Arun creates different rules:
- Bala can read the project report.
- Bala cannot delete any files.
- Another student, Kumar, cannot access the locker.
- Arun has complete control over his storage.
These rules are similar to the permissions defined in an S3 bucket policy.
A bucket policy tells Amazon S3:
- Who can access the bucket or objects?
- What actions are allowed?
- What actions are denied?
- Which resources do the permissions apply to?
Important elements of a bucket policy
A bucket policy is written using JSON.
Let's understand its important fields.
1. Effect
Defines whether an action is allowed or denied.
Values:
- Allow
- Deny
2. Principal
Defines who is allowed or denied access.
For example, a specific IAM user, AWS account, AWS service or everyone (
* ).3. Action
Defines what the user can do.
Examples:
-
s3:GetObject– Read or download an object.
-
s3:PutObject– Upload an object.
-
s3:DeleteObject– Delete an object.
4. Resource
Defines which S3 bucket or objects the rule applies to.
Example: Allowing public read access
Suppose Arun creates a bucket named
my-school-website and wants everyone to view the website files.He can use the following bucket policy:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowPublicRead", "Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::my-school-website/*" } ]}Let's understand this policy:
-
Effect: Allowmeans permission is granted.
-
Principal: *means everyone, including anonymous internet visitors.
-
Action: s3:GetObjectmeans users can read or download objects.
-
Resourceidentifies all objects inside the specified bucket.
Notice that we have not given permission to upload or delete files.
This is an example of read-only public access.
Important: This policy alone does not make a bucket public if applicable Block Public Access settings prevent public access. Those settings must also be considered.
Example: Blocking a particular user
Let's imagine Arun does not like another student named Bala accessing his private files.
Arun wants to prevent Bala from downloading any objects from his bucket.
He can define an explicit Deny statement in a bucket policy:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Deny", "Principal": { "AWS": "arn:aws:iam::123456789012:user/Bala" }, "Action": "s3:GetObject", "Resource": "arn:aws:s3:::arun-private-storage/*" } ]}Here:
- The Principal identifies Bala's IAM user.
- Effect is Deny.
- Action is
s3:GetObject.
- Resource identifies all objects inside Arun's private bucket.
Even if another applicable policy allows Bala to read the object, this explicit Deny prevents that access.
Remember: In AWS permissions evaluation, an explicit Deny overrides an Allow.
The account ID and username above are placeholders. They must be replaced with the actual IAM identity details.
5. What is an ACL in Amazon S3?
ACL stands for Access Control List.
It is another mechanism for managing access permissions to S3 buckets and individual objects.
Let's understand the difference using our school example.
Arun has five important documents inside his storage locker.
He wants to give his friend Kumar permission to read only one particular document.
Instead of giving Kumar access to the entire locker, Arun gives him permission for that specific document.
This is the basic idea behind object-level access control using ACLs.
In Amazon S3:
- Bucket ACLs control certain permissions at the bucket level.
- Object ACLs control certain permissions at the individual object level.
ACLs can grant basic permissions such as READ and WRITE to specified AWS accounts or predefined groups.
Bucket Policy vs ACL
Bucket Policy | ACL |
|---|---|
Uses JSON | Uses predefined permissions and grants |
Controls access at bucket and object level | Can control access at bucket and object level |
Supports Allow and Deny | Provides basic grants; no explicit Deny |
More flexible | More limited |
Recommended for most modern use cases | Usually not required |
Important AWS concept:
For newly created general-purpose S3 buckets, the default Object Ownership setting is
Bucket owner enforced .Under this setting, ACLs are disabled. The bucket owner owns the objects, and access is managed using policies.
AWS recommends keeping ACLs disabled for most modern applications unless a particular use case requires them.
6. What is Block Public Access?
Block Public Access is an Amazon S3 security feature that helps prevent unwanted public access to buckets and objects.
Let's understand this with a real-life example.
Imagine Arun has a personal storage locker.
One day, a stranger comes to the college and tries to open Arun's locker.
Arun has already instructed the college security guard:
"Do not allow any unknown person to open my locker, even if someone tries to give them permission."
The security guard acts as an additional layer of protection.
Similarly, S3 Block Public Access provides an additional security layer that prevents public access through public bucket policies and ACLs.
Amazon S3 provides four Block Public Access settings:
-
BlockPublicAcls
-
IgnorePublicAcls
-
BlockPublicPolicy
-
RestrictPublicBuckets
These settings protect S3 resources against unwanted public access.
Important: New S3 buckets have all four Block Public Access settings enabled by default.
Even if someone adds a public bucket policy, the applicable Block Public Access settings can prevent that public access from working.
Public Access vs Private Access
Public Access:
Anyone on the internet can access the objects for which public permissions have been granted, without needing an authenticated AWS identity.
Example: A publicly accessible college website image.
Private Access:
Only authorized users or services with the required permissions can access the objects.
Example: Arun's personal certificates and confidential college documents.
Security recommendation: Keep Block Public Access enabled for private storage. Do not make an entire bucket public just to share one file. Use a private bucket and a presigned URL when temporary access to an individual object is sufficient.
7. What is Static Website Hosting in Amazon S3?
Static website hosting is a feature that allows us to host a website using files stored in an S3 bucket.
Let's understand this with a real-world example.
Imagine a college wants to publish its website.
The website contains:
- Homepage
- About Us page
- Contact page
- College photographs
- CSS files
- JavaScript files
Instead of maintaining a traditional web server just to serve these static files, the college can store its website files in an S3 bucket and configure static website hosting.
For example, Arun creates a bucket named:
arun-college-website He uploads the following files:
index.htmlabout.htmlcontact.htmlstyle.cssscript.jsimages/ college.jpg logo.pngNow he enables Static Website Hosting in the bucket properties.
He can configure:
Index document:
index.html This is the main page that visitors see when they open the website.
Error document:
error.html This page can be displayed when a requested website resource is not found.
Amazon S3 provides a website endpoint through which visitors can access the hosted website.
How does it work?
- Create an S3 bucket.
- Upload your HTML, CSS, JavaScript and image files.
- Enable Static Website Hosting.
- Configure the index document.
- Configure the error document if required.
- Configure the necessary access permissions for your hosting setup.
- Open the website endpoint to test your website.
Important: Does static website hosting support backend code?
No. Amazon S3 static website hosting serves static website content.
It can host:
- HTML
- CSS
- JavaScript
- Images
- Other static assets
However, it does not directly execute server-side code such as Node.js, Java, PHP or Python.
If your application requires backend functionality, you need additional services such as Amazon EC2, AWS Lambda or other backend services.
Can we use HTTPS with an S3 static website endpoint?
S3 static website endpoints support HTTP, not HTTPS.
For a more secure website setup, we can use Amazon CloudFront in front of an S3 bucket.
CloudFront supports HTTPS and Origin Access Control (OAC), which allows us to keep the S
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article