Amazon S3 for Beginners: Buckets, Objects, Storage Classes, Versioning, Permissions and Static Website Hosting
What Is S3?
Amazon Simple Storage Service (S3) is object storage: you store files (objects) in buckets and get them back over the internet or the AWS network. It is built for 11 nines (99.999999999 percent) durability, which means your data is extremely unlikely to be lost.
- Store photos, videos, backups, logs, website files, data lakes, software downloads
- Unlimited total storage. One object can be up to 5 TB
- You pay for storage used, requests and data transferred out
- S3 is Regional: your data stays in the Region you choose, copied across multiple AZs
Buckets and Objects
| Term | Meaning |
| Bucket | Container for objects. Name must be globally unique, lowercase, 3-63 characters |
| Object | The file (data) plus metadata |
| Key | The object's full name, like photos/2026/trip.jpg. S3 looks flat. The slashes are just part of the name (shown as folders in the console) |
| Prefix | The beginning of a key, like photos/2026/, used to group and filter |
| Version ID | Identifies one version when versioning is on |
Your First Bucket
bash
aws s3 mb s3://my-demo-bucket-111111111111-ap-south-1 --region ap-south-1
echo "hello s3" > hello.txt
aws s3 cp hello.txt s3://my-demo-bucket-111111111111-ap-south-1/docs/hello.txt
aws s3 ls s3://my-demo-bucket-111111111111-ap-south-1/ --recursive
aws s3 sync ./site s3://my-demo-bucket-111111111111-ap-south-1/site --delete
aws s3 cp s3://my-demo-bucket-111111111111-ap-south-1/docs/hello.txt ./copy.txt
aws s3 rm s3://my-demo-bucket-111111111111-ap-south-1/docs/hello.txt
Storage Classes
| Class | Use | Retrieval |
| S3 Standard | Frequently used data | Instant |
| S3 Intelligent-Tiering | Unknown or changing access. S3 moves data automatically | Instant (with automatic archive tiers optional) |
| S3 Standard-IA (Infrequent Access) | Backups and data you read rarely but need fast. Retrieval fee | Instant |
| S3 One Zone-IA | Re-creatable infrequent data in a single AZ (cheaper, less resilient) | Instant |
| S3 Glacier Instant Retrieval | Archive you read about once a quarter | Milliseconds |
| S3 Glacier Flexible Retrieval | Archive, free bulk retrieval | Minutes to hours |
| S3 Glacier Deep Archive | Cheapest, long-term retention (years) | Hours (12 or more) |
- Lifecycle rules automatically move or delete objects: for example 'after 30 days move to Standard-IA, after 90 days to Glacier, after 365 days delete'
- Archive classes have minimum storage durations, so do not use them for short-lived data
json
{"Rules":[{"ID":"logs-tiering","Status":"Enabled","Filter":{"Prefix":"logs/"},
"Transitions":[{"Days":30,"StorageClass":"STANDARD_IA"},{"Days":90,"StorageClass":"GLACIER"}],
"Expiration":{"Days":365},"AbortIncompleteMultipartUpload":{"DaysAfterInitiation":7}}]}
Versioning
- Keeps every version of an object. Overwrites create a new version. A delete adds a delete marker so you can recover
- Turn it on for important buckets. Once enabled it can be suspended, not removed
- Old versions cost storage, so add a lifecycle rule for old versions
bash
aws s3api put-bucket-versioning --bucket my-demo-bucket-111111111111-ap-south-1 --versioning-configuration Status=Enabled
aws s3api list-object-versions --bucket my-demo-bucket-111111111111-ap-south-1 --prefix docs/hello.txt
Security and Access
| Control | What it does |
| Block Public Access | Four switches that stop buckets from becoming public. Keep ON (also at account level) |
| IAM policies | Give users and roles permission |
| Bucket policy | Resource policy on the bucket. For cross-account access, conditions (IP, VPC endpoint, HTTPS only) |
| ACLs | Old method. Use Bucket owner enforced to turn ACLs off |
| Encryption | SSE-S3 is automatic for all new objects. SSE-KMS for key control and audit |
| Presigned URL | A temporary link to download or upload one object without giving permissions |
| Access Points | Different entry points with their own policy for teams |
| MFA Delete / Object Lock | Extra protection against deletion (WORM) |
bash
aws s3api put-public-access-block --bucket my-demo-bucket-111111111111-ap-south-1 \
--public-access-block-configuration BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true
aws s3 presign s3://my-demo-bucket-111111111111-ap-south-1/docs/hello.txt --expires-in 600
Most data leaks come from public buckets Keep Block Public Access on. Share files with presigned URLs or CloudFront instead of making the bucket public.
Static Website Hosting
S3 can serve a static website (HTML, CSS, JavaScript, images). Best practice today: keep the bucket private and serve it through CloudFront with Origin Access Control, which also gives HTTPS and a custom domain.
bash
aws s3 website s3://my-site-bucket --index-document index.html --error-document error.html # simple test mode (public website endpoint)
aws s3 sync ./site s3://my-site-bucket --delete
Other Useful Features
- Replication (cross-Region and same-Region) copies new objects automatically
- Event notifications trigger Lambda, SQS or SNS when objects arrive
- Transfer Acceleration speeds uploads from faraway users
- Multipart upload splits big files (use for objects over 100 MB)
- S3 Inventory and Storage Lens show what you store
- S3 Select / Athena query data in place
- Requester Pays makes the downloader pay the transfer cost
Pricing in Simple Words
| You pay for | Notes |
| Storage (GB per month) | Depends on class and Region |
| Requests (PUT, GET, LIST...) | Per thousand requests |
| Data transfer out to the internet | Data in is free. Transfer to CloudFront and within the same Region to AWS services is cheaper or free in many cases |
| Retrieval and transitions | For IA and Glacier classes |
Practice
- Create a bucket, upload a file and download it
- Turn on versioning, overwrite the file and list versions
- Add a lifecycle rule for a
logs/ prefix
- Create a presigned URL that expires in 5 minutes
- Host a one-page website using CloudFront and a private bucket
Conclusion
S3 stores unlimited objects in buckets with very high durability. Choose the right storage class and lifecycle rules, enable versioning and encryption, keep Block Public Access on, share with presigned URLs, and use CloudFront in front of static sites.
Quick Summary: S3; buckets and objects; first bucket; classes; versioning; security; website; features; pricing.