Storage
S3 — Object Storage
Store and retrieve any amount of data from Amazon S3 — the foundation of AWS storage.
Amazon S3
Amazon Simple Storage Service (S3) stores objects (files) in buckets (containers). It's infinitely scalable, highly available, and used for:
- Static website hosting
- Application assets (images, videos, documents)
- Backups and archives
- Data lakes and analytics
- Software distribution
Key Concepts
- Bucket: Container for objects. Globally unique name.
- Object: A file + metadata. Up to 5TB per object.
- Key: The object's path/name within the bucket
- Region: Where data is stored
- ACL/Bucket Policy: Controls access permissions
Storage Classes
- Standard: Frequently accessed data
- Intelligent-Tiering: Auto moves between tiers
- Standard-IA: Infrequently accessed
- Glacier: Long-term archive (minutes to hours retrieval)
- Glacier Deep Archive: Cheapest, 12-hour retrieval
Example
bash
# Create a bucket
aws s3 mb s3://my-unique-bucket-name-2024
# Upload a file
aws s3 cp file.txt s3://my-bucket/
aws s3 cp file.txt s3://my-bucket/path/to/file.txt
# Upload entire directory
aws s3 sync ./dist s3://my-bucket/website --delete
# Download a file
aws s3 cp s3://my-bucket/file.txt .
# List objects in bucket
aws s3 ls s3://my-bucket/
aws s3 ls s3://my-bucket/ --recursive --human-readable
# Delete objects
aws s3 rm s3://my-bucket/file.txt
aws s3 rm s3://my-bucket/ --recursive
# Enable static website hosting
aws s3 website s3://my-bucket --index-document index.html --error-document error.html
# Bucket policy for public read (static website)
aws s3api put-bucket-policy --bucket my-bucket --policy '{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-bucket/*"
}]
}'
# Presigned URL (temporary access)
aws s3 presign s3://my-bucket/private-file.pdf --expires-in 3600Try it yourself — BASH