💡 Ask Tutor

Amazon S3 – Deep Dive into Scalable Object Storage

What is Amazon S3?

Amazon S3 (Simple Storage Service) is an object storage service that offers scalability, durability, availability, and security for storing and retrieving data from anywhere on the web.

It’s ideal for everything from static websites and backups to big data analytics, IoT data lakes, and media hosting.

📌 Durability: S3 provides 99.999999999% (11 9’s) durability across multiple Availability Zones.

🧱 Core Concepts of S3

ConceptDescription
BucketTop-level container for storing objects (files)
ObjectThe data stored (file) + metadata
KeyUnique identifier (full path) for an object within a bucket
RegionThe AWS Region in which the bucket is hosted
Storage ClassDetermines durability, availability, and cost (Standard, IA, Glacier, etc.)

🎯 Buckets are globally unique, and the name becomes part of the URL (e.g., https://mybucket.s3.amazonaws.com/myfile.jpg).

Creating an S3 Bucket (Step-by-Step)

Method 1: AWS Console

  1. Open S3 Console
  2. Click Create Bucket
  3. Set:
    • Bucket Name (must be globally unique)
    • Region
  4. Configure:
    • Public access (usually blocked by default)
    • Versioning, encryption, logging
  5. Click Create Bucket

Method 2: AWS CLI

Bash
aws s3 mb s3://my-scriptbuzz-bucket --region ap-south-1

S3 Storage Classes – Use Based on Access Patterns

Storage ClassUse CaseDurabilityAvailabilityCost
StandardFrequently accessed data11 9’s99.99%$$$
Intelligent-TieringAutomatic tiering based on usage11 9’s99.9–99.99%$$
Standard-IA (Infrequent Access)Rarely accessed but critical11 9’s99.9%$
One Zone-IASingle-AZ storage for rarely used data11 9’s99.5%$
GlacierArchival storage, minutes retrieval11 9’s99.99%¢
Glacier Deep ArchiveLong-term cold storage (hours to access)11 9’s99.99%¢

🔐 Securing Your S3 Bucket

✅ Best Practices:

  • Block Public Access unless explicitly required
  • Use Bucket Policies to control access
  • Enable Versioning to preserve, retrieve, and restore objects
  • Use Server-Side Encryption (SSE-S3, SSE-KMS)
  • Enable MFA Delete to add a layer of protection

Example Bucket Policy (Allow public read for static site):

JSON
{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Principal": "*",
    "Action": ["s3:GetObject"],
    "Resource": ["arn:aws:s3:::my-website-bucket/*"]
  }]
}

📡 Hosting a Static Website on S3

S3 allows you to host static websites (HTML/CSS/JS) with high availability.

🧪 Steps:

  1. Enable Static Website Hosting on your bucket
  2. Upload index.html, error.html
  3. Set permissions via bucket policy
  4. Access via:
    http://my-bucket.s3-website.ap-south-1.amazonaws.com

✅ You can connect a custom domain via Route 53 and CloudFront for HTTPS & global CDN.

📁 Uploading Files – Methods

1. Using AWS Console:

  • Drag & drop files into the bucket
  • Manage folders, metadata, permissions

2. Using AWS CLI:

Bash
aws s3 cp myfile.jpg s3://mybucket/images/

3. Using SDK (Python – Boto3):

Python
import boto3
s3 = boto3.client('s3')
s3.upload_file('local.jpg', 'mybucket', 'uploads/image.jpg')

S3 Object Versioning & Lifecycle Rules

✅ Versioning:

  • Keeps multiple variants of an object
  • Protects against accidental deletion

✅ Lifecycle Rules:

  • Automatically transition objects to lower-cost storage
  • Delete old versions or incomplete uploads
JSON
"Transitions": [{
  "Days": 30,
  "StorageClass": "GLACIER"
}]

S3 Monitoring & Analytics

  • Use AWS CloudWatch to track storage usage
  • Enable Server Access Logs for request-level logs
  • S3 Storage Lens provides organization-wide usage dashboards

🛡️ Real-World Use Cases

IndustryUse Case
Media & EntertainmentStore, stream, and archive videos and images
SaaS/StartupsHost static frontend (HTML/CSS/JS)
HealthcareStore encrypted patient records (HIPAA compliant)
E-commerceProduct image storage and backups
IoT/AnalyticsSensor data lakes, logs, and batch analytics

⚖️ S3 vs EBS vs EFS – Quick Comparison

FeatureS3EBSEFS
TypeObject StorageBlock StorageFile Storage (NFS)
Use CaseMedia, backupsEC2 OS/data disksShared access (multiple EC2s)
AccessAPI, webAttached to EC2Mount like a drive
ScalabilityInfiniteLimited per volumeScalable and shared

📌 Summary

FeatureValue
S3 PurposeScalable, durable object storage
Key ComponentsBuckets, objects, keys, metadata
Storage ClassesStandard, IA, Glacier, Deep Archive
Static Site HostingDirect from S3, global access via CloudFront
SecurityIAM, Bucket Policies, Encryption, MFA
AutomationLifecycle policies, S3 event triggers
MonitoringCloudWatch, Storage Lens, Access Logs