Lesson 2 of 11 · 11 min · Cloud basics
Storage in the cloud: object, block and file
What you will learn
- Object, block and file storage, and which to use
- S3: buckets, keys, durability, consistency, storage classes
- Versioning, delete markers, lifecycle rules and encryption
- Blocking public access, bucket policies and presigned URLs
- EBS volumes and EFS file systems
In simple words
The cloud offers three kinds of storage. Object storage is a huge locker room for whole files such as photos and backups. Block storage is a hard disk attached to one machine. File storage is a shared folder that many machines can open. Picking the right one is half the job.
Words to know
- Object storage (S3): storage for whole files. Each one is fetched by its name.
- Bucket: a container for objects in S3. Its name is unique across the world.
- Block storage (EBS): a virtual disk attached to a virtual machine.
- Lifecycle rule: an automatic rule such as "move files to cheaper storage after 30 days".
Three kinds of storage
| Type | Interface | Used like | AWS | Azure | Google Cloud |
|---|---|---|---|---|---|
| Object | HTTP API (PUT/GET by key) | a huge key-value store for files: backups, media, logs, data lakes, static websites | S3 | Blob Storage | Cloud Storage |
| Block | raw disk attached to one VM | the VM's disk: OS, databases | EBS | Managed Disks | Persistent Disk |
| File | network file system (NFS/SMB) shared by many | shared directories | EFS, FSx | Azure Files | Filestore |
Object storage: S3
Amazon S3 stores objects (a file plus metadata) in buckets. Key facts:
- A bucket name is globally unique and lives in one region. An object is identified by its key, such as
docs/hello.txt. There are no real folders; the/in keys is just a character, and the console shows "folders" by prefix. Objects can be up to 5 TB. - Very high durability (designed for 99.999999999%, "11 nines", by storing copies across at least three zones) and high availability. Since late 2020 S3 provides strong read-after-write consistency: after a successful write, any read sees it.
- Access is by HTTP API (SDKs, CLI, presigned URLs), not by mounting like a disk (although mount helpers exist, they behave differently from a real filesystem).
- You pay for storage per GB-month, requests, and data transfer out to the internet (inbound is free; transfer within the same region to services like EC2 is typically free, cross-region and internet egress are charged).
Basic use:
aws s3 mb s3://demo-assets
aws s3 cp hello.txt s3://demo-assets/docs/hello.txt
aws s3 ls s3://demo-assets/ --recursive
aws s3 sync ./site s3://demo-assets/site --delete
2026-11-12 14:55:58 12 docs/hello.txt
Storage classes
Pick the class by how often data is read:
| Class | For | Notes |
|---|---|---|
| Standard | frequently accessed data | default |
| Intelligent-Tiering | unknown or changing access patterns | moves objects between tiers automatically for a small monitoring fee |
| Standard-IA / One Zone-IA | infrequent access, rapid retrieval | lower storage price, retrieval fee, minimum duration |
| Glacier Instant / Flexible Retrieval | archives | cheaper still; retrieval takes milliseconds to hours depending on the class |
| Glacier Deep Archive | long-term retention (compliance) | cheapest; retrieval in hours |
Versioning and delete markers
With versioning enabled every overwrite creates a new version, and a delete adds a delete marker instead of removing data. We tested it:
aws s3api put-bucket-versioning --bucket demo-assets --versioning-configuration Status=Enabled
aws s3api delete-object --bucket demo-assets --key docs/hello.txt # returns DeleteMarker: true
aws s3 ls s3://demo-assets/ --recursive | wc -l # 0: the object looks deleted
aws s3api list-object-versions --bucket demo-assets --query 'DeleteMarkers[].Key' # docs/hello.txt
After the delete the listing shows nothing, but the data is still there under earlier versions, and removing the delete marker (deleting that version id) restores it. Versioning protects against accidental overwrite and deletion (and against ransomware); it costs storage for old versions, so pair it with a lifecycle rule. Enable MFA Delete or Object Lock (WORM: write once, read many) for the strictest protection.
Lifecycle rules
Automate cost control and clean-up:
{"Rules":[{"ID":"archive-then-expire","Status":"Enabled","Filter":{"Prefix":"logs/"},
"Transitions":[{"Days":30,"StorageClass":"STANDARD_IA"},{"Days":90,"StorageClass":"GLACIER"}],
"Expiration":{"Days":365}}]}
aws s3api put-bucket-lifecycle-configuration --bucket demo-assets --lifecycle-configuration file://lc.json
Logs under logs/ move to Infrequent Access after 30 days, to Glacier after 90, and are deleted after a year. Also add rules to delete non-current versions and incomplete multipart uploads, which otherwise accumulate silently.
Security: block public access, encrypt, restrict
Public S3 buckets are among the most common causes of data leaks. Defaults today are safe (new buckets block public access and encrypt), but verify and enforce:
aws s3api put-public-access-block --bucket demo-assets --public-access-block-configuration \
BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true
aws s3api put-bucket-encryption --bucket demo-assets --server-side-encryption-configuration \
'{"Rules":[{"ApplyServerSideEncryptionByDefault":{"SSEAlgorithm":"AES256"}}]}'
Our test read them back: all four public-access settings true and encryption AES256. Encryption choices: SSE-S3 (AWS-managed keys, as above), SSE-KMS (your KMS key, with audit and access control, see the KMS lesson), or client-side. Do the account-wide version too: S3 Block Public Access at account level so no bucket can be made public by mistake.
A bucket policy is a resource-based IAM policy. A common one denies any request not using HTTPS:
{"Version":"2012-10-17","Statement":[{"Sid":"DenyInsecureTransport","Effect":"Deny","Principal":"*",
"Action":"s3:*","Resource":["arn:aws:s3:::demo-assets","arn:aws:s3:::demo-assets/*"],
"Condition":{"Bool":{"aws:SecureTransport":"false"}}}]}
Prefer IAM roles for applications to access buckets; use bucket policies for cross-account access and for blanket guard rails. Do not use ACLs for new designs (disabled by default via "Bucket owner enforced").
Sharing without making it public: presigned URLs
A presigned URL grants temporary access to one object using the signer's permissions:
aws s3 presign s3://share-bucket/inv.txt --expires-in 300
Fetching the signed URL returned the file's content (invoice 42). After it expires (here 5 minutes) the same URL fails. Use presigned URLs for downloads in a web application, and presigned PUT URLs so browsers upload directly to S3 without passing through your server. Real S3 answers 403 Forbidden to an unsigned request for a private object.
Static websites and CDN
S3 can host static sites, but the modern pattern is a private bucket behind CloudFront (the CDN) with an origin access control, giving HTTPS, caching at edge locations close to users, and custom domains.
Other features worth knowing
Event notifications (trigger Lambda/SQS on upload), replication (same-region or cross-region), access points, Storage Lens and Inventory for large buckets, aws s3 sync for backups, multipart upload for big files, request-rate scaling per prefix.
Block storage: EBS
An EBS volume is a network-attached disk for one EC2 instance (in one AZ). Types: gp3 (general-purpose SSD, default; set size, IOPS and throughput independently), io2 (high-performance), st1/sc1 (throughput-optimised/cold HDD). Create one:
aws ec2 create-volume --availability-zone ap-south-1a --size 20 --volume-type gp3
vol-b738ed4c 20 gp3 creating
Key facts: volumes persist independently of instances (unless "delete on termination"), live in a single AZ, can be resized online, and are backed up with snapshots (incremental, stored in S3; copy across regions; schedule with Data Lifecycle Manager / AWS Backup). Always encrypt volumes (account default setting). Instance store volumes are fast local disks that disappear when the instance stops: only for caches and scratch data.
File storage: EFS
EFS is managed NFS: many Linux instances (or containers) mount the same file system across zones; it grows automatically and costs more per GB than EBS or S3. Use it for shared content, home directories and some CMS or ML workloads. FSx offers Windows file shares, Lustre and NetApp.
Choosing
- Files accessed by an application over HTTP, backups, media, logs, data lake → S3.
- A database or OS disk on one server → EBS (or better: a managed database).
- A directory many servers share → EFS.
- Anything that must survive the instance → not the instance's local disk.
Common mistakes
- Public buckets, or relying on ACLs.
- No versioning or lifecycle rules (data loss, or storage growing forever).
- Treating S3 like a filesystem (renames are copy plus delete; listing millions of keys is slow).
- Forgetting data-transfer and request costs.
- Unencrypted volumes and snapshots shared publicly.
- Embedding access keys in code instead of using IAM roles.
- Single-AZ EBS for important data without snapshots.
Try it yourself
- Create a bucket, upload a file, enable versioning, delete the object and find the delete marker. Restore the object by deleting the marker.
- Add a lifecycle rule that transitions
logs/to infrequent access and expires after a year. - Generate a presigned URL, fetch it, and try it after expiry.
- Attach a bucket policy that denies non-HTTPS requests and verify with the policy simulator or a test request.
Check yourself
What is the difference between S3 and EBS?
S3 is object storage accessed over HTTP, shared, regional and extremely durable. EBS is a block device attached to a single EC2 instance in one AZ, used as a disk.
What does versioning do when you delete an object?
It adds a delete marker instead of removing data; earlier versions remain and can be restored by removing the marker.
How can you give a user temporary access to a private object without changing permissions?
Create a presigned URL with an expiry; it carries the signer's authorisation for that one operation until it expires.
Name three controls that prevent S3 data leaks.
Block Public Access (account and bucket level), least-privilege IAM and bucket policies with HTTPS enforcement, and encryption with logging/monitoring (plus versioning and Object Lock for integrity).
Interview questions
How would you store user-uploaded files for a web application?
Upload directly to a private S3 bucket using presigned PUT URLs, store only the key and metadata in the database, serve through CloudFront or presigned GET URLs, encrypt at rest, scan uploads if needed, and set lifecycle rules.
How do you reduce S3 costs?
Right storage class (Intelligent-Tiering or lifecycle transitions), expire old data and old versions, abort incomplete multipart uploads, compress, avoid unnecessary cross-region transfer, and serve through a CDN.
When would you choose EFS over S3?
When applications need a POSIX shared filesystem with file locking and low-latency random access across many instances; S3 is better when HTTP access and scale/cost matter.
Summary
- Object (S3), block (EBS) and file (EFS) storage serve different needs; use S3 for most files and data.
- S3: global-unique buckets, keys not folders, 11-nines durability, storage classes, versioning with delete markers, lifecycle rules.
- Lock it down: block public access, encrypt, enforce HTTPS, use roles; share with presigned URLs.
- EBS volumes are per-AZ disks backed up by snapshots; EFS is shared NFS.
Going deeper
- Amazon S3 User Guide: buckets, objects and every feature.
- S3 storage classes: comparison and use cases.
- Security best practices for S3: public access, encryption and monitoring.
- Amazon EBS user guide: volume types and snapshots.
- Amazon EFS user guide: shared file storage.
See how much of this you can explain
A free mock interview asks you new questions on Cloud platforms and AWS fundamentals for DevOps Engineer and scores every answer, with what to fix.