AWS S3 Storage
Amazon S3 (Simple Storage Service) stores files of any type and size, safely and cheaply, in the cloud.
What is S3?
S3 is object storage. You do not get a disk with folders like on your laptop. Instead you get:
- Buckets: containers for your files. Each bucket name is unique across all of AWS.
- Objects: the files you store, such as images, PDFs, videos or backups.
- Keys: the full name of an object, like
products/shirt-blue.jpg.
S3 is used for website images, app uploads, backups, logs and data for analysis. It is designed to keep your data very safe by copying it across several data centres.
Creating a Bucket
In the console: open S3, click Create bucket, type a name and choose a region.
With the CLI (mb means "make bucket"):
Example
aws s3 mb s3://ayesha-notes-2026 --region ap-south-1make_bucket: ayesha-notes-2026
Bucket name rules:
- 3 to 63 characters
- Only lowercase letters, numbers, dots and hyphens
- Must be unique in the whole world, so add something personal like your name
Uploading and Downloading Files
Copy a file to the bucket:
Example
aws s3 cp result-card.pdf s3://ayesha-notes-2026/2026/result-card.pdfupload: ./result-card.pdf to s3://ayesha-notes-2026/2026/result-card.pdf
List what is inside:
Example
aws s3 ls s3://ayesha-notes-2026/2026/2026-10-15 11:42:03 84213 result-card.pdf
Download it again:
Example
aws s3 cp s3://ayesha-notes-2026/2026/result-card.pdf ./download.pdfTo copy a whole folder and only send changed files, use sync:
Example
aws s3 sync ./website s3://ayesha-notes-2026/siteThe 2026/ part of the key looks like a folder in the console, but S3 is flat. It is simply part of the object's name.
Storage Classes
You can choose a storage class to save money on files you rarely open:
| Storage class | Best for |
|---|---|
| S3 Standard | Files used often, like website images |
| S3 Intelligent-Tiering | Unknown access patterns; AWS moves files automatically |
| S3 Standard-IA | Files used rarely but needed quickly |
| S3 Glacier classes | Archives and old backups, cheapest but slower to get back |
Lifecycle rules can move objects to cheaper classes automatically, for example "move logs to Glacier after 90 days".
Keeping Data Private
New buckets are private by default, and Block Public Access is turned on. Keep it that way unless you really need public files.
To share one private file for a short time, create a pre-signed URL:
Example
aws s3 presign s3://ayesha-notes-2026/2026/result-card.pdf --expires-in 3600The link works for one hour (3600 seconds), then stops working.
You can also turn on:
- Versioning: keeps old versions when a file is overwritten or deleted
- Encryption: S3 encrypts new objects by default
Hosting a Static Website
S3 can serve a simple website made of HTML, CSS, JavaScript and images (no PHP or database).
- Create a bucket and upload
index.html - In Properties, turn on Static website hosting and set the index document to
index.html - Turn off Block Public Access for this bucket and add a bucket policy that allows public reading
A bucket policy for public reading looks like this:
Example
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::ayesha-portfolio-site/*"
}]
}For a real site, put CloudFront (AWS's content delivery network) in front of the bucket to get HTTPS and faster loading.
Deleting a Bucket
A bucket must be empty before you delete it. The --force option empties and deletes it in one step:
Example
aws s3 rb s3://ayesha-notes-2026 --forceExercise
Exercise
In Amazon S3, what is a bucket?
