AWS S3 — Storage, Hosting, and CDN Guide

Sanjeev SharmaSanjeev Sharma
1 min read

Advertisement

AWS S3 — Storage, Hosting, and CDN Guide

S3 provides scalable object storage for data, backups, and static web hosting.

Bucket Operations

# Create bucket
aws s3 mb s3://my-bucket

# List objects
aws s3 ls s3://my-bucket

# Upload file
aws s3 cp file.txt s3://my-bucket/

# Upload directory
aws s3 sync ./local-dir s3://my-bucket/

# Download
aws s3 cp s3://my-bucket/file.txt ./

# Delete
aws s3 rm s3://my-bucket/file.txt

Static Website Hosting

# Enable static hosting
aws s3 website s3://my-bucket \
  --index-document index.html \
  --error-document error.html

# Upload files
aws s3 sync ./dist s3://my-bucket/

# Website URL: http://my-bucket.s3-website-us-east-1.amazonaws.com

CloudFront CDN

# Create distribution
aws cloudfront create-distribution --distribution-config file://config.json

FAQ

Q: How do I make S3 objects public? A: Use bucket policies and ACLs. Recommended: use CloudFront with OAI for better security.

Q: What's S3 versioning? A: Keeps multiple versions of objects. Enable for backup protection.

Advertisement

Sanjeev Sharma

Written by

Sanjeev Sharma

Full Stack Engineer · E-mopro