Amazon S3 basics
-
Phase 0: Before you start
-
Phase 1: The foundation
-
Phase 2: Operations and security
-
Phase 3: SQL Server on AWS
-
Phase 4: Troubleshooting step by step
-
Phase 5: Final project and career
Almost every AWS job ends up touching S3. Backups land there, logs get shipped there, and SQL Server native backups (Lesson 46) are restored from there. These Amazon S3 basics are the commands you’ll be typing every week: creating a bucket, uploading and syncing, listing and downloading, picking a storage class and sharing one file safely.
You’ll do all of it from your laptop with the CLI. There’s no server or VPC involved, so the lab costs a fraction of a cent.
| Time | You need | By the end you can |
|---|---|---|
| 45 minutes | Your laptop with the AWS CLI signed in as saat-admin (Lesson 6). If aws --version shows a release older than March 2026, update it first with winget upgrade Amazon.AWSCLI. Cost: well under USD 0.01. | Create a bucket in your own account namespace, upload and sync files, make sense of prefixes, pick a storage class, share a file with a presigned URL and delete a bucket cleanly. |
What it is, in one line
Amazon S3 is a storage service where you keep files (objects) in containers (buckets) and reach them over HTTPS from wherever you allow.
In Simple Words
A bank locker room
Think of the locker room at a bank. Your bucket is your locker, sitting in one branch (a Region), and every item you put inside carries a label like “reports/2026-10/sales.csv”. There aren’t any real drawers in there; the slashes in the label only help you find things.
Nobody but you can open the locker unless you allow it. If a friend needs one document you don’t give them your key, you give them a slip that works for five minutes and only for that item, and that slip is a presigned URL. The bank also has a cheaper back room for things you rarely touch, where storage costs less each month but you pay a little every time you take something out.
Engineer's View
What S3 really is
S3 is object storage, not a file system. An object is made of a key (its full name), the data, and metadata such as content type and storage class. One object can be as big as 50 TB, but a single upload request tops out at 5 GB, so for big files the CLI switches to multipart upload on its own.
A bucket lives in one Region. In the shared global namespace, a bucket name has to be unique across every AWS account in the world. Since March 2026 you can create buckets in your account regional namespace instead, where the name ends in -ACCOUNTID-REGION-an and nobody but your account can ever use it.
A new bucket starts private and locked down: Block Public Access is on, ACLs are disabled (bucket owner enforced) and every new object gets SSE-S3 encryption. S3 is also strongly consistent, so once a PUT succeeds the very next GET or LIST will see it. Access is controlled by IAM policies and bucket policies (Lesson 17), and never by keeping the URL secret.
How it works, step by step
This is the path a file takes when you upload it.
1The CLI signs a request
aws s3 cp signs an HTTPS PUT to the bucket’s Regional endpoint using your saat-admin credentials, and without a valid signature you get nowhere.
2S3 stores the object
S3 encrypts the data, stores it across several Availability Zones and records the key, size, ETag and storage class. demo/reports/2026-10/sales.csv is a single key, not three nested folders.
3You choose a storage class
The storage class decides what you pay each month and what it costs to read the data back. You can set it on each object when you upload, or let lifecycle rules (Lesson 18) move objects later.
4Someone reads it
Only signed requests from principals that have permission get through. When one person needs one file for a short while, you sign the URL for them, and that’s a presigned URL.
These are the storage classes you’ll come across most:
Standard-IA bills every object for at least 30 days and at least 128 KB, so it’s good for larger backups that stay a while and a bad fit for thousands of tiny log files.
✅ Checkpoint: You can explain bucket, object, key and prefix, say why new buckets are private, and say when Standard-IA is a poor choice.
Hands-on lab: Amazon S3 basics from the CLI
Before you run any command, double-check it
Read every command twice before you press Enter. Check the target: the system or account, the IDs, the names and the sizes. These commands are for learning and were tested in our lab, not on your system. At work, run the read-only list commands first, follow your change process, make sure a backup exists, and ask a second person to check anything that changes or deletes data. You run them at your own risk.
Sign in and set your variables. The bucket name uses your account regional namespace, so it can’t clash with anybody else’s:
cd C:\aws-lab
aws login --profile saat-admin
$env:AWS_PROFILE = 'saat-admin'
$acct = aws sts get-caller-identity --query Account --output text
$bucket = "saat-lab-$acct-ap-south-1-an"
$bucketYou should see something like this:
saat-lab-111122223333-ap-south-1-an1Create the bucket and check its defaults
Paste this whole block:
aws s3api create-bucket --bucket $bucket --bucket-namespace account-regional --region ap-south-1 --create-bucket-configuration LocationConstraint=ap-south-1
aws s3api put-bucket-tagging --bucket $bucket --tagging 'TagSet=[{Key=course,Value=saatvedha-aws},{Key=lesson,Value=16}]'
aws s3api get-public-access-block --bucket $bucket --query PublicAccessBlockConfiguration --output text
aws s3api get-bucket-encryption --bucket $bucket --query "ServerSideEncryptionConfiguration.Rules[0].ApplyServerSideEncryptionByDefault.SSEAlgorithm" --output textYou should see something like this:
{
"Location": "http://saat-lab-111122223333-ap-south-1-an.s3.amazonaws.com/"
}
True True True True
AES256All four Block Public Access settings are on and SSE-S3 (AES256) is the default, without you doing anything. If the CLI says Unknown options: --bucket-namespace, your CLI is older than the feature, so run winget upgrade Amazon.AWSCLI and open a new window.
2Upload one file, then sync a folder
Paste this whole block:
New-Item -ItemType Directory -Force s3demo\reports\2026-10, s3demo\logs | Out-Null
Set-Content s3demo\reports\2026-10\sales.csv "date,store,amount`n2026-10-01,Pune,48200`n2026-10-01,Chennai,51750"
Set-Content s3demo\logs\app.log "2026-10-01 10:15:02 INFO app started"
Set-Content readme.txt "Lesson 16 test file"
aws s3 cp readme.txt "s3://$bucket/"
aws s3 sync .\s3demo "s3://$bucket/demo/"You should see something like this:
upload: .\readme.txt to s3://saat-lab-111122223333-ap-south-1-an/readme.txt
upload: s3demo\logs\app.log to s3://saat-lab-111122223333-ap-south-1-an/demo/logs/app.log
upload: s3demo\reports\2026-10\sales.csv to s3://saat-lab-111122223333-ap-south-1-an/demo/reports/2026-10/sales.csvRun the same sync a second time and it prints nothing, because nothing has changed. sync only copies new or changed files, which is why teams like it for nightly backups.
3List and understand prefixes
Paste this whole block:
aws s3 ls "s3://$bucket/"
aws s3 ls "s3://$bucket/demo/"
aws s3 ls "s3://$bucket" --recursive --human-readable --summarizeYou should see something like this:
PRE demo/
2026-10-20 14:32:10 21 readme.txt
PRE logs/
PRE reports/
2026-10-20 14:32:12 38 Bytes demo/logs/app.log
2026-10-20 14:32:12 66 Bytes demo/reports/2026-10/sales.csv
2026-10-20 14:32:10 21 Bytes readme.txt
Total Objects: 3
Total Size: 125 BytesPRE stands for prefix. The console draws prefixes as folders, but the recursive list tells you what’s really there: three objects with long names.

4Pick a storage class
Paste this whole block:
aws s3 cp .\s3demo\logs\app.log "s3://$bucket/archive/app.log" --storage-class STANDARD_IA
aws s3api head-object --bucket $bucket --key archive/app.log --query StorageClass --output text
aws s3api head-object --bucket $bucket --key demo/logs/app.log --query StorageClass --output textYou should see this:
upload: s3demo\logs\app.log to s3://saat-lab-111122223333-ap-south-1-an/archive/app.log
STANDARD_IA
NoneNone isn’t an error. S3 doesn’t return a storage class for Standard objects, so an empty value means S3 Standard. In Standard-IA this 38-byte file is billed as 128 KB, which is the reason tiny files don’t belong there.
5Download, then share one file safely
Paste this whole block:
aws s3 cp "s3://$bucket/demo/reports/2026-10/sales.csv" .\downloaded-sales.csv
Get-Content .\downloaded-sales.csv
$direct = "https://$bucket.s3.ap-south-1.amazonaws.com/demo/reports/2026-10/sales.csv"
try { Invoke-WebRequest -UseBasicParsing $direct | Out-Null } catch { $_.Exception.Message }
$url = aws s3 presign "s3://$bucket/demo/reports/2026-10/sales.csv" --expires-in 300
(Invoke-WebRequest -UseBasicParsing $url).StatusCodeYou should see something like this:
download: s3://saat-lab-111122223333-ap-south-1-an/demo/reports/2026-10/sales.csv to .\downloaded-sales.csv
date,store,amount
2026-10-01,Pune,48200
2026-10-01,Chennai,51750
The remote server returned an error: (403) Forbidden.
200The plain URL gets refused because the bucket is private. The presigned URL works for 300 seconds, for that one object, using your permissions, and once five minutes are up the same link returns 403.
✅ Checkpoint: Your bucket exists with Block Public Access and AES256, sync copies only what changed, archive/app.log is STANDARD_IA, the direct URL gives 403 and the presigned URL gives 200. Keep the bucket for the break lab.
Break It, Then Fix It
Two errors you’ll almost certainly see in your first month, one while creating buckets from scripts and one while cleaning them up.
1Break it: create a bucket without a location
Try creating a second bucket, but leave out the location constraint:
aws s3api create-bucket --bucket "saat-test-$acct-ap-south-1-an" --bucket-namespace account-regional --region ap-south-1You’ll get this error:
An error occurred (IllegalLocationConstraintException) when calling the CreateBucket operation: The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.
The low-level s3api create-bucket call assumes N. Virginia (us-east-1) unless you tell it otherwise, and you sent it to the Mumbai endpoint. Scripts copied from blog posts written for us-east-1 fail in just this way.
Fix: with s3api, always pass --create-bucket-configuration LocationConstraint=ap-south-1, or use aws s3 mb, which adds it for you. You don’t need the second bucket, so leave it.
2Break it: delete a bucket that still has objects
Try removing your lab bucket:
aws s3 rb "s3://$bucket"You’ll get this error:
remove_bucket failed: s3://saat-lab-111122223333-ap-south-1-an An error occurred (BucketNotEmpty) when calling the DeleteBucket operation: The bucket you tried to delete is not emptyS3 won’t delete a bucket that still has objects in it. That’s there to protect you, so look at what’s inside before you empty it. Fix: preview with --dryrun, empty it and then delete it:
aws s3 rm "s3://$bucket" --recursive --dryrun
aws s3 rm "s3://$bucket" --recursive
aws s3 rb "s3://$bucket"
Remove-Item -Recurse s3demo, readme.txt, downloaded-sales.csv
.\Find-LabResources.ps1The last few lines will look something like this:
delete: s3://saat-lab-111122223333-ap-south-1-an/readme.txt
remove_bucket: saat-lab-111122223333-ap-south-1-anaws s3 rb --force does both steps at once, which is handy in a lab and risky in production. If versioning is on (Lesson 18), the old versions stay behind and the bucket still won’t delete until you remove them too.
✅ Checkpoint: You fixed IllegalLocationConstraintException by adding a location constraint and saw BucketNotEmpty protect a bucket. The lesson 16 bucket and your local files are gone.
This happened at work
The sync that deleted the archive
A hospital IT team copied scanned patient forms from a file server to S3 every night using aws s3 sync D:\scans s3://forms-archive/ --delete. The --delete flag kept the bucket an exact copy of the server, and nobody stopped to think what “exact copy” would mean on a bad day. Then, during a storage migration, an engineer pointed the D: drive at a new volume that was still empty, just for one evening. The nightly job ran on time and removed about 300,000 objects from the bucket to match the empty drive, and since versioning was off there was nothing to undo.
It took two tense days to rebuild the forms from the old volume, which luckily was still around. Afterwards the team took --delete out of every backup job, turned on versioning with a lifecycle rule that expires old versions after 60 days, and added a check that stops the job if the source folder has fewer files than it did the night before.
Common mistakes and troubleshooting
| Mistake | What happens | What to do |
|---|---|---|
| Forgetting the location constraint in s3api create-bucket | IllegalLocationConstraintException outside us-east-1 | Pass LocationConstraint or use aws s3 mb |
Using sync with --delete for backups | A wrong or empty source wipes out the copy | Back up without --delete and switch on versioning |
| Treating prefixes as real folders | Scripts and permissions miss some objects | Think in full keys, and use --recursive and prefixes in policies |
| Tiny files in Standard-IA or Glacier | Each one is billed as at least 128 KB, plus the minimum days | Keep small files in Standard or use Intelligent-Tiering |
| Making a bucket public to share one file | The data is open to the whole internet | Use a presigned URL with a short expiry |
Running aws s3 rb --force in the wrong profile | A production bucket gets emptied | Run aws sts get-caller-identity first, and use --dryrun |
Interview questions
Click a question to open it. They’re worded the way an interviewer would ask them, and under each one you’ll find why they ask it and one way to answer, which you should put in your own words.
Fresher level
1. Can you explain in simple words the difference between a bucket and an object in S3?
Why they ask this: It’s basic S3 vocabulary, and everything else in S3 builds on these two ideas.
How you might answer: A bucket is a container in one Region with a name nobody else can use, and an object is a file stored inside it, made up of its key, its data and its metadata.
2. A new team member asks, “Are S3 folders real?” What would you tell them?
Why they ask this: They want to know you understand prefixes, because that matters when you write policies, lifecycle rules and scripts.
How you might answer: I’d tell them no. Keys are flat names and the slashes are part of the key; the console and the CLI only show common prefixes as folders to make browsing easier.
3. A customer needs to download one private file from your bucket, but only for the next hour. How would you do that?
Why they ask this: They want to see you can share data safely without making a bucket public, since public buckets are behind a lot of data leaks.
How you might answer: I’d generate a presigned URL that expires in one hour. The bucket stays private, and the link only works for that one object until it runs out.
2–5 years experience
4. What’s the difference between Standard-IA and Intelligent-Tiering, and when would you pick each?
Why they ask this: They’re checking you understand storage class trade-offs, because picking the wrong one can push costs up instead of down.
How you might answer: Standard-IA is for larger objects I know are read rarely and kept for at least 30 days. If the access pattern is unknown or keeps changing, I’d go with Intelligent-Tiering, which moves objects around by itself with no retrieval fees in exchange for a small monitoring charge per object.
5. A colleague asks why you sometimes use aws s3 and sometimes aws s3api. How would you explain the difference?
Why they ask this: It shows deeper CLI knowledge. Knowing when to drop down to the API level helps a lot with scripts and debugging.
How you might answer: aws s3 gives me high-level commands like cp, sync, ls and rb, and takes care of multipart uploads and recursion. aws s3api maps one-to-one to the API operations, so I reach for s3api when I need full control over a parameter, like tagging, head-object or the location constraint.
6. A nightly sync job to S3 takes a little longer every week. What would you look at?
Why they ask this: It’s practical troubleshooting. Slow jobs are usually down to the design, not S3 itself.
How you might answer: I’d look at how many objects there are, how long the source scan takes, and whether it’s listing the whole bucket every run. I’d check the network path too, NAT versus a gateway endpoint, and the CLI concurrency settings. After that I’d ask whether something smarter fits better, like date-based prefixes or S3 Batch Operations.
Senior level
7. You’re setting standards for S3 across 30 application teams. How would you design bucket naming and layout?
Why they ask this: They want platform standards that stop problems before they start, and the security defaults matter as much as the names.
How you might answer: I’d put bucket names in the account regional namespace with a standard prefix, one bucket per application and environment, and make tags mandatory. Block Public Access would be on at account level, with default KMS encryption where it’s required, and every bucket would get versioning and lifecycle rules. An SCP would deny creating buckets outside the account namespace.
8. Someone ran sync --delete against an empty source folder and wiped a bucket. How do you recover, and how do you stop it happening again?
Why they ask this: They want calm incident handling plus real prevention, because fixing it once isn’t enough if the same job can run again tomorrow night.
How you might answer: If versioning is on, I’d remove the delete markers to bring the objects back, using a script or S3 Batch Operations, and without versioning I’d restore from AWS Backup or whatever other copy exists. To stop it happening again I’d turn on versioning, use Object Lock for critical data, take --delete out of backup jobs and check the source object count before every sync.
Quick quiz
Q1. What is an S3 object key?
- The encryption key
- The full name of the object, including any prefixes
- The bucket name
- An access key ID
Show answer
B: The key is the object’s full name, for example demo/reports/2026-10/sales.csv.
Q2. Why did the lab get IllegalLocationConstraintException?
- The bucket name was taken
- The location constraint was missing in a non-us-east-1 Region
- Block Public Access was on
- The CLI was old
Show answer
B: Outside us-east-1, s3api create-bucket needs a LocationConstraint.
Q3. What does head-object show as StorageClass for a Standard object?
- STANDARD
- Nothing (None)
- DEFAULT
- An error
Show answer
B: S3 only returns StorageClass for classes other than Standard.
Q4. What is the safest way to give one person one private file for a short time?
- Make the bucket public
- A presigned URL with an expiry
- Email your access keys
- Turn off encryption
Show answer
B: A presigned URL gives temporary access to that one object.
Q5. Why does aws s3 rb fail on a bucket with files in it?
- S3 never deletes buckets that still have objects
- The bucket is encrypted
- Your profile is wrong
- Buckets can’t be deleted
Show answer
A: You have to empty the bucket first, or use --force in a lab.
Quick recap
- A bucket is Regional, and an object is a key plus data plus metadata.
- Names in the account regional namespace end in -ACCOUNTID-REGION-an and can’t clash with any other account.
- New buckets start private and encrypted with SSE-S3.
- sync only copies what changed, and you should be careful with
--delete. - Share with presigned URLs, and empty a bucket before deleting it.
Next lesson
Lesson 17: S3 security: Block Public Access, bucket policies, encryption → You’ll write bucket policies, enforce encryption and TLS, and lock a bucket down to your VPC endpoint.
Further reading: Amazon S3 basics
Want to go deeper into Amazon S3 basics? Read What is Amazon S3? and Namespaces for general purpose buckets. You can also see the full plan for this course on the AWS Cloud Administration course page.
