Learn to Code
All tracks
Learn to Code

Free lessons from scratch to pro — every language, databases and DevOps.

AboutContactPrivacy PolicyTerms of Use

Your progress is saved in this browser. © 2026 Learn to Code

CL
Cloud (AWS, GCP, Azure)
0/12 completed
Beginner
What is cloud computing?AWS, Google Cloud and Azure comparedAccounts, billing alerts and the CLI
Intermediate
Identity and access (IAM)Virtual machinesObject storageNetworking: VPCs, subnets and load balancersManaged databases
Advanced
Serverless: functions, queues and eventsContainers in the cloud
Pro
Infrastructure as codeCost control, security and reliability
Tracks / Cloud (AWS, GCP, Azure) / Intermediate

Object storage

Object storage keeps files ("objects") of any size in buckets, with virtually unlimited space, eleven nines (99.999999999%) of durability, and pay-per-gigabyte pricing. It's where the cloud keeps user uploads, images, videos, backups, logs, data lakes and static websites. AWS calls it S3, Google Cloud Cloud Storage, and Azure Blob Storage.

Buckets and objects

Concept Meaning
Bucket A container with a globally unique name, in one region
Object A file plus metadata, up to 5 TB
Key The object's name: photos/2026/beach.jpg. There are no real folders: / is just part of the name, and tools display it as folders
Storage class Price/speed trade-off: frequent access, infrequent, archive
bash
aws s3 mb s3://acme-media-2026
mkdir -p site/img && echo "<h1>Hello</h1>" > site/index.html && echo "fake image" > site/img/logo.png
aws s3 cp site/index.html s3://acme-media-2026/ --no-progress
aws s3 sync site s3://acme-media-2026/site --no-progress
aws s3 ls s3://acme-media-2026 --recursive | awk '{ print $3, $4 }'
aws s3 cp s3://acme-media-2026/site/index.html - 
Output
make_bucket: acme-media-2026
upload: site/index.html to s3://acme-media-2026/index.html
upload: site/img/logo.png to s3://acme-media-2026/site/img/logo.png
upload: site/index.html to s3://acme-media-2026/site/index.html
15 index.html
11 site/img/logo.png
15 site/index.html
<h1>Hello</h1>
Command Does
aws s3 cp src dst Copy a file to/from a bucket (- = stdout)
aws s3 sync dir s3://b/prefix Upload only new or changed files (add --delete to mirror deletions)
aws s3 ls s3://b --recursive List objects
aws s3 mv, aws s3 rm Move, delete
aws s3api … The full low-level API (versioning, policies, lifecycle…)

Google Cloud: gcloud storage cp|ls|rsync. Azure: az storage blob upload|list|sync or the azcopy tool.

Keep buckets private

Every bucket should be private unless it deliberately hosts public files. All three providers now block public access by default; keep it that way:

bash
aws s3api get-public-access-block --bucket acme-media-2026 --query "PublicAccessBlockConfiguration" --output table 2>/dev/null \
  || aws s3api put-public-access-block --bucket acme-media-2026 --public-access-block-configuration \
     BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true
aws s3api get-public-access-block --bucket acme-media-2026 --query "PublicAccessBlockConfiguration" --output table
Output
-----------------------------------
|      GetPublicAccessBlock       |
+-------------------------+-------+
|  BlockPublicAcls        |  True |
|  BlockPublicPolicy      |  True |
|  IgnorePublicAcls       |  True |
|  RestrictPublicBuckets  |  True |
+-------------------------+-------+

Publicly readable buckets holding private data have caused some of the largest data leaks ever. To share a private file, use a pre-signed URL, a link that grants temporary access to one object:

bash
aws s3 presign s3://acme-media-2026/site/index.html --expires-in 600 \
  | sed -E 's#^https?://[^/]+/acme-media-2026/#https://acme-media-2026.s3.ap-south-1.amazonaws.com/#; s/(X-Amz-(Credential|Date|Signature))=[^&]*/\1=…/g'
Output
https://acme-media-2026.s3.ap-south-1.amazonaws.com/site/index.html?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=…&X-Amz-Date=…&X-Amz-Expires=600&X-Amz-SignedHeaders=host&X-Amz-Signature=…

The link works for 10 minutes for anyone who has it, then stops. Apps use pre-signed URLs for downloads and also for uploads: the browser uploads directly to S3, and your server never handles the file. Google Cloud calls them signed URLs; Azure SAS tokens.

To serve public files (images, a website), put a CDN (CloudFront, Cloud CDN, Front Door) in front of a private bucket, rather than making the bucket public.

Versioning: undo for your bucket

With versioning, overwriting or deleting an object keeps the old version:

bash
aws s3api put-bucket-versioning --bucket acme-media-2026 --versioning-configuration Status=Enabled
echo "version 1" > notes.txt && aws s3 cp notes.txt s3://acme-media-2026/notes.txt --no-progress > /dev/null
echo "version 2" > notes.txt && aws s3 cp notes.txt s3://acme-media-2026/notes.txt --no-progress > /dev/null
aws s3 rm s3://acme-media-2026/notes.txt > /dev/null
echo "after delete:"; aws s3 ls s3://acme-media-2026/notes.txt || echo "  (not listed)"
echo "but the versions are still there:"
aws s3api list-object-versions --bucket acme-media-2026 --prefix notes.txt \
  --query "{versions: length(Versions), deleteMarkers: length(DeleteMarkers)}" --output text
oldest=$(aws s3api list-object-versions --bucket acme-media-2026 --prefix notes.txt --query "Versions[-1].VersionId" --output text)
aws s3api get-object --bucket acme-media-2026 --key notes.txt --version-id "$oldest" restored.txt > /dev/null && cat restored.txt
Output
after delete:
  (not listed)
but the versions are still there:
1	2
version 1

The delete only added a delete marker; both versions can be restored. Turn versioning on for any bucket whose data matters (combined with a lifecycle rule to delete old versions after a while, so costs don't grow forever). It's a strong defence against accidental deletion and ransomware.

Storage classes and lifecycle rules

Prices fall as access gets rarer:

Class (AWS) Google Cloud Azure For
S3 Standard Standard Hot Frequently accessed data
S3 Standard-IA Nearline Cool Accessed about monthly
S3 Glacier Instant/Flexible Retrieval Coldline Cold Accessed a few times a year
S3 Glacier Deep Archive Archive Archive Kept for compliance; hours to restore, very cheap
S3 Intelligent-Tiering Autoclass (lifecycle management) Unknown patterns: moves data automatically

A lifecycle rule moves or deletes objects automatically as they age:

lifecycle.json
{
  "Rules": [
    {
      "ID": "logs-to-archive",
      "Status": "Enabled",
      "Filter": { "Prefix": "logs/" },
      "Transitions": [
        { "Days": 30, "StorageClass": "STANDARD_IA" },
        { "Days": 90, "StorageClass": "GLACIER" }
      ],
      "Expiration": { "Days": 365 }
    },
    {
      "ID": "clean-old-versions",
      "Status": "Enabled",
      "Filter": {},
      "NoncurrentVersionExpiration": { "NoncurrentDays": 30 }
    }
  ]
}
bash
aws s3api put-bucket-lifecycle-configuration --bucket acme-media-2026 --lifecycle-configuration file://lifecycle.json
aws s3api get-bucket-lifecycle-configuration --bucket acme-media-2026 --query "Rules[].[ID, Status]" --output text
Output
logs-to-archive	Enabled
clean-old-versions	Enabled

Encryption

Objects are encrypted at rest by default on all three clouds. For sensitive data, use keys you control in the key management service (AWS KMS, Cloud KMS, Azure Key Vault), so access to the data also requires permission to use the key, and every use is logged:

bash
aws s3api get-bucket-encryption --bucket acme-media-2026 --query "ServerSideEncryptionConfiguration.Rules[0].ApplyServerSideEncryptionByDefault" --output json 2>/dev/null || echo '(default encryption: SSE-S3)'
Output
(default encryption: SSE-S3)

Always use HTTPS to talk to storage (the CLIs and SDKs do by default); a bucket policy with the condition "aws:SecureTransport": "false" → Deny enforces it.

Using it from code

python
import boto3

s3 = boto3.client("s3")
s3.upload_file("report.pdf", "acme-media-2026", "reports/2026/q3.pdf")
url = s3.generate_presigned_url("get_object", Params={"Bucket": "acme-media-2026", "Key": "reports/2026/q3.pdf"}, ExpiresIn=600)
for obj in s3.list_objects_v2(Bucket="acme-media-2026", Prefix="reports/").get("Contents", []):
    print(obj["Key"], obj["Size"])

Every language has an official SDK (boto3 for Python, @aws-sdk/client-s3 for JavaScript, google-cloud-storage, @azure/storage-blob), and on a VM or function with a role, they find credentials automatically.

Clean up

bash
aws s3 rm s3://acme-media-2026 --recursive > /dev/null
aws s3api delete-objects --bucket acme-media-2026 --delete "$(aws s3api list-object-versions --bucket acme-media-2026 --query '{Objects: [Versions, DeleteMarkers][][].{Key: Key, VersionId: VersionId}}' --output json)" > /dev/null
aws s3 rb s3://acme-media-2026 && echo "bucket removed"
Output
remove_bucket: acme-media-2026
bucket removed

A versioned bucket must have all versions deleted before it can be removed.

Practice

  1. Create a bucket, sync a folder to it, change one file, and sync again: check that only one file is uploaded.
  2. Generate a pre-signed URL that expires in 60 seconds and test it with curl before and after it expires.
  3. Turn on versioning, overwrite a file twice, and restore the first version.
  4. Write a lifecycle rule that deletes objects under tmp/ after 7 days.
✎ Check your understanding

1.How should you give a user temporary access to one private object?

2.What happens when you delete an object in a versioned bucket?

3.Which storage class fits backups kept for 7 years and almost never read?

4.Are S3 "folders" real directories?

← Virtual machines