devHọc Dev

Week 3 - Day 2: Storage (Advanced S3, Storage Gateway, EBS, EFS, FSx)

Week 3 – Day 2

This lesson combines 2 topics: S3 Advanced & Storage Gateway, EBS, EFS, FSx Deep Dive.

Learning Objectives

  • Understand advanced S3 features
  • Master S3 Access Points and Object Lambda
  • Know the Storage Gateway use cases
  • Choose the right EBS volume type by IOPS/throughput/cost and understand Multi-Attach
  • Understand EFS storage classes and performance/throughput modes
  • Choose the right FSx variant by protocol and workload (Windows/HPC/NetApp/OpenZFS)

Part 1: S3 Advanced & Storage Gateway

1. S3 Access Points

┌─────────────────────────────────────────────────────────┐│S3ACCESSPOINTS││││Problem:Complexbucketpoliciesformulti-tenant││││Solution:││┌─────────────────────────────────────────────────┐│││S3Bucket││││││││┌──────────────┐┌──────────────┐│││││AccessPoint1││AccessPoint2││││││(FinanceTeam)││(Analytics)││││││prefix:/fin/││prefix:/data/││││││VPConly││Public│││││└──────────────┘└──────────────┘│││└─────────────────────────────────────────────────┘││││EachAccessPoint:││-OwnDNSname││-Ownaccesspolicy││-Networkcontrols(VPCorpublic)│└─────────────────────────────────────────────────────────┘

Multi-Region Access Points

┌─────────────────────────────────────────────────────────┐│MULTI-REGIONACCESSPOINTS││││Singleglobalendpoint→Nearestbucket││││┌─────────────────────────────────────────────────┐│││mrap.mrap.s3-global.amazonaws.com│││││││││┌──────────────┼──────────────┐││││▼▼▼││││us-east-1eu-west-1ap-se-1││││bucketbucketbucket││││││││+S3Cross-RegionReplication│││└─────────────────────────────────────────────────┘││││Benefits:││-Automaticroutingtonearestbucket││-Failoversupport││-Replicationtimecontrol│└─────────────────────────────────────────────────────────┘

2. S3 Object Lambda

┌─────────────────────────────────────────────────────────┐│S3OBJECTLAMBDA││││Transformdataasit'sretrieved:││││┌─────────────────────────────────────────────────┐│││Client│││││││││▼GETrequest││││ObjectLambdaAccessPoint│││││││││▼││││LambdaFunction(transform)│││││││││▼││││S3Bucket(originaldata)│││└─────────────────────────────────────────────────┘││││Usecases:││-RedactPII││-Convertformats(JSONtoXML)││-Resizeimageson-the-fly││-Addwatermarks│└─────────────────────────────────────────────────────────┘

3. S3 Batch Operations

For bulk operations on billions of objects:

Supported Operations:
- Copy objects
- Invoke Lambda function
- Replace tags
- Replace ACL
- Restore from Glacier
- Object Lock retention
- Replication (S3 Batch Replication)

Input: S3 Inventory report or CSV manifest

4. Storage Gateway

Types

┌─────────────────────────────────────────────────────────┐│STORAGEGATEWAYTYPES││││1.S3FILEGATEWAY││On-prem──NFS/SMB──►Gateway──►S3││FilesstoredasS3objects││││2.FSxFILEGATEWAY││On-prem──SMB──►Gateway──►FSxforWindows││Windowsfileshares││││3.VOLUMEGATEWAY││Cached:Hotdatalocal,fulldatainS3││Stored:Fulldatalocal,asyncbackuptoS3││Blockstorage(iSCSI)││││4.TAPEGATEWAY││VirtualtapelibrarybackedbyS3/Glacier││Forbackupapplications│└─────────────────────────────────────────────────────────┘

5. S3 Pre-signed URLs

┌─────────────────────────────────────────────────────────┐│S3PRE-SIGNEDURL││││Client(noAWScredentials)││││││1.RequestURL││▼││AppServer/Lambda(hasIAMpermissions)││││││2.SignURLwithitsowncredentials│││(SigV4,withexpiration)││▼││Pre-signedURL──►Client││││││3.GET/PUTdirectlytoS3(bypassingserver)││▼││S3Bucket(objectstaysprivate)│└─────────────────────────────────────────────────────────┘

How it works: the URL contains a SigV4 signature + expiration → anyone holding the URL can GET/PUT that object without AWS credentials, within the allowed period.

Key points for the exam:

  • The URL inherits the permissions of the principal that signed it. If the signer does not have s3:GetObject on that object → the generated URL is still syntactically valid but useless (Access Denied).
  • Maximum validity is 7 days with SigV4 when signed with IAM user credentials (long-term access keys).
  • Common exam trap: signing with temporary credentials (IAM Role — EC2 instance profile, Lambda execution role, STS AssumeRole) → the URL dies when the session token expires, even if you set a longer expiration. Need a long-lived URL → sign with IAM user credentials (or extend the session).
  • Per-object: each URL allows exactly 1 operation (GET or PUT) on exactly 1 object key.

Use cases:

  • Direct upload from the client: a browser/mobile app PUTs straight to S3, bypassing the app server → less load, lower bandwidth cost through the server.
  • Time-limited sharing of private files: send a download link that expires after X hours without making the bucket public.

S3 Pre-signed URL vs CloudFront Signed URL/Cookies

CriterionS3 Pre-signed URLCloudFront Signed URL/Cookies
PathAccesses S3 directlyThrough the CDN (edge caching, low latency)
OriginS3 onlyS3 or a custom origin (ALB, EC2, on-prem)
ScopePer-object, per-operation (GET/PUT)Signed URL: per-file; Signed Cookies: MANY files (Resource pattern such as /videos/*)
Key managementNo dedicated key — signed with IAM credentials, easy to generate (SDK/CLI)Key groups (public/private key pair that you manage and rotate)
ConditionsExpiration onlyExpiration + IP range restriction, date range (custom policy)
UploadSupports PUT (direct upload)Mainly for content distribution (download/streaming)

Exam keywords:

  • "serve private content through CDN", "video streaming of many files to subscribers" → CloudFront Signed URL/Cookies (many files → Signed Cookies)
  • "temporary direct upload/download to S3", "client upload without going through the server" → S3 Pre-signed URL

6. Advanced CloudFront for SAP-C02

Origin Groups (Origin Failover)

┌─────────────────────────────────────────────────────────┐│CLOUDFRONTORIGINGROUP+S3CRR││││Users──►CloudFrontDistribution│││││▼││┌─OriginGroup─────────────────┐│││││││PrimarySecondary││││S3us-east-1──►S3eu-west-1│││││failoveron▲│││││5xx/timeout│││││└────S3CRR───────┘│││└────────────────────────────────┘││││Primaryfail(500/502/503/504,timeout)││→CloudFrontauto-retriestherequestonsecondary│└─────────────────────────────────────────────────────────┘
  • Origin Group = primary + secondary origin; CloudFront fails over when the primary returns configurable HTTP status codes (500, 502, 503, 504, and 403/404 if selected) or on timeout/connection failure.
  • Classic SAP-C02 pattern: Origin Group + S3 Cross-Region Replication → multi-Region HA origin for static content, no Route 53 failover needed, no client changes needed.
  • Applies only to GET/HEAD/OPTIONS (no failover for PUT/POST).

Geo Restriction

  • Blocks/allows access to a distribution by country (GeoIP database) — configured as an allowlist OR blocklist at the distribution level.
  • Use case: compliance/licensing — content may only be released in certain countries (film rights, legal regulations).
  • Blocked viewers receive HTTP 403 (a custom error page is possible).
  • Distinguish from Route 53 Geolocation routing: Route 53 routes users to different endpoints by location (they are still served, only the destination differs); CloudFront Geo Restriction blocks access entirely. "Block users from country X" → CloudFront Geo Restriction; "serve different content/endpoint per region" → Route 53 Geolocation.

Price Class

Price ClassEdge locationsTrade-off
AllAll of them (including South America, Australia...)Best performance everywhere, highest cost
200Most regions (excluding the most expensive ones)Balanced
100Only US, Canada, Europe (+ Israel)Cheapest, users outside US/EU get higher latency
  • Price Class only limits the edge locations that serve content — users in excluded regions can still access it (routed to a farther edge), just more slowly.
  • Exam keyword: "reduce CloudFront cost", "users mostly in US/EU" → Price Class 100.

Part 2: EBS, EFS, FSx Deep Dive

1. EBS Volume Types

┌─────────────────────────────────────────────────────────┐│EBSVOLUMETYPES││││SSD-backed:││├──gp3:Generalpurpose(baseline3000IOPS)││├──gp2:Generalpurpose(IOPSscaleswithsize)││├──io2(BlockExpress):upto256,000IOPS,64TiB│││(04/2025:allio2=BlockExpress;io1max64K)││└──io1:upto64,000IOPS,16TiB(legacy)││││HDD-backed:││├──st1:Throughputoptimized(500MB/s)││└──sc1:ColdHDD(250MB/s,lowestcost)│└─────────────────────────────────────────────────────────┘

Multi-Attach (io1/io2)

  • Attach the same volume to up to 16 instances
  • Same AZ only
  • Cluster-aware file system required (GFS2)
  • Use case: HA applications

2. EBS Snapshots

Fast Snapshot Restore (FSR):
- Eliminate initialization latency
- Per AZ fee
- Good for: Boot volumes, AMIs

Snapshot Archive:
- 75% cost savings
- 24-72 hours retrieval
- Good for: Compliance, long-term backup

3. EFS (Elastic File System)

┌─────────────────────────────────────────────────────────┐│EFS││││Filesystemtype:││├──Regional(Multi-AZ)││└──OneZone(singleAZ,cheaper)││││StorageClasses:││├──EFSStandard(SSD,sub-mslatency)││├──EFSInfrequentAccess(IA):fewtimes/quarter││└──EFSArchive(11/2023):fewtimes/yearorless││(Regionalonly,Elasticthroughput,min90days)││││Lifecycle:Standard→IA→Archivebylastaccess││││PerformanceModes:││├──GeneralPurpose(latency-sensitive)││└──MaxI/O(thousandsofclients)││││ThroughputModes:││├──Bursting(scaleswithsize)││├──Provisioned(fixedthroughput)││└──Elastic(auto-scale,new)│└─────────────────────────────────────────────────────────┘

Lifecycle management moves files based on their last access time in Standard: for example "after 30 days → IA, after 90 days → Archive", and you can enable "transition back to Standard on first access". EFS Archive is only available on Regional file systems (One Zone does not support it), has a 90-day minimum storage charge, is up to 50% cheaper than IA, and only works with Elastic throughput — once the lifecycle includes a step into Archive, you cannot switch to Bursting/Provisioned. Exam keyword: "rarely accessed file share data, keep it on NFS, most cost-effective" → lifecycle to EFS Archive (no need to move it to S3).

4. FSx Options

ServiceProtocolUse Case
FSx for WindowsSMBWindows apps, AD integration
FSx for LustreLustreHPC, ML, video processing
FSx for NetApp ONTAPNFS, SMB, iSCSIEnterprise, hybrid
FSx for OpenZFSNFSLinux workloads

FSx for Lustre + S3

┌─────────────────────────────────────────────────────────┐│FSxforLustre+S3Integration││││S3Bucket(datarepository)││↕Lazyload/Writeback││FSxforLustre(high-speedprocessing)││↕││ComputeInstances(EC2,ECS,EKS)││││Usecase:ProcesslargedatasetsfromS3│└─────────────────────────────────────────────────────────┘

5. Amazon Data Lifecycle Manager (DLM)

Automates the lifecycle of EBS snapshots and EBS-backed AMIs: creates them on a schedule, keeps them per a retention rule, deletes them on expiry — no custom Lambda/cron needed.

┌─────────────────────────────────────────────────────────┐│DATALIFECYCLEMANAGER(DLM)││││LifecyclePolicy(tag-basedtargeting)││├──Target:taggedvolumes/instances│││(e.g.Backup=true,Env=prod)││├──Schedule:every1/2/3/4/6/8/12/24horcron││├──Retention:keepthelastNcopiesorNdays││└──Actions:││├──CreateEBSsnapshot/EBS-backedAMI││├──Cross-accountsnapshotcopy(shareDRaccount)││├──Cross-Regioncopy││└──Auto-enableFastSnapshotRestore(FSR)│└─────────────────────────────────────────────────────────┘

What a Professional needs to know:

  • Tag-based: apply standardized tags (via an Organizations tag policy) → new volumes are backed up automatically, no policy changes needed.
  • Cross-account copy: a policy in the source account shares snapshots with the DR account; the destination account can have its own policy to copy further cross-Region + re-encrypt with the destination account's KMS key — a DR/backup isolation pattern.
  • DLM is free — you only pay for snapshot storage (and FSR if enabled).

DLM vs AWS Backup

CriterionDLMAWS Backup
ScopeOnly EBS snapshots + EBS-backed AMIsMulti-service: EBS, EC2, RDS, Aurora, DynamoDB, EFS, FSx, S3, Storage Gateway, VMware...
PolicySimple: tag + schedule + retentionCentralized backup plan, backup vault
ComplianceNoVault Lock (WORM), auditing via Backup Audit Manager
Cross-region/accountSnapshot copy (EBS only); cross-account copy via snapshot sharing, no Organizations requiredYes, for every supported service; cross-account copy requires the accounts to be in the same AWS Organization
OrganizationsNot directlyBackup policies applied across the Organization
CostFree (pay for snapshots)Pay for backup storage/restore (some services have separate fees)

Exam keywords:

  • "automate EBS snapshot lifecycle", "delete snapshots older than N days", "least effort for EBS only" → DLM
  • "centralized backup across multiple services/accounts", "compliance/immutable backup", "enforce backup policy across the Organization" → AWS Backup (+ Vault Lock)

6. EFS Access Points

Access Point = a per-application entry point into an EFS file system:

  • Enforce POSIX identity: every request through the access point runs with a preconfigured user/group ID — ignoring the NFS client's identity (even root on the client is mapped to the access point's UID/GID).
  • Dedicated root directory (chroot-style): each app only sees its own directory (e.g. /app1), created automatically with a predefined owner/permissions.
  • Combine with a file system policy (IAM resource policy) using the condition elasticfilesystem:AccessPointArn → forces an app/role to access only through a specific access point, not mount the root directly.
┌─────────────────────────────────────────────────────────┐│EFSACCESSPOINTS(multi-tenant)││││AppA(EC2)LambdaFnAppB(ECS)│││││││▼▼▼││AccessPoint1AccessPoint2AccessPoint3││UID/GID1001UID/GID1002UID/GID1003││root:/app-aroot:/lambdaroot:/app-b│││││││└────────────────┼────────────────┘││▼││┌─────────────────────────────┐│││EFSFileSystem(single)││││/app-a/lambda/app-b│││└─────────────────────────────┘│└─────────────────────────────────────────────────────────┘

Main use cases:

  • Multi-tenant shared EFS: many teams/apps share 1 file system but isolate data + identity — no need to manage UID/GID on each client.
  • Lambda + EFS: Lambda must mount EFS through an access point (it cannot mount the file system directly) — used for large ML models, shared state between invocations, libraries larger than the /tmp limit.
  • Least privilege: a file system policy denies all access that does not go through an access point → each app can only read/write its own directory.

Exam keywords: "multiple applications share one EFS with isolated directories", "enforce POSIX permissions regardless of client", "Lambda needs shared persistent storage" → EFS Access Points.


Review Questions

  1. What problem do S3 Access Points solve?

    Show answer

    S3 Access Points solve complex bucket policies when many teams/applications need to access the same bucket with different permissions. Instead of one giant bucket policy: create an Access Point per use case with its own policy (e.g. an AP for the analytics team, an AP for the app team, an AP for data science). Each AP has its own hostname and its own policy. They also support VPC restriction (an AP accessible only from a specific VPC).

  2. How do Multi-Region Access Points work?

    Show answer

    MRAP provides a single global endpoint that routes requests to the nearest S3 bucket (lowest latency). You need S3 CRR (Cross-Region Replication) between the buckets to sync data. When a request reaches the MRAP endpoint → AWS routes it to the bucket in the Region with the lowest latency. If a Region fails → automatic failover to the next best Region. Use it for: global apps that need low-latency reads, active-active multi-region storage architectures.

  3. What is S3 Object Lambda used for?

    Show answer

    S3 Object Lambda lets you add transformation code to S3 GET requests — without copying data. A Lambda function intercepts the S3 request and transforms the response before returning it to the client. Use cases: (1) Data redaction (mask PII based on user permissions), (2) Format conversion (CSV → JSON, resize images), (3) Add watermarks, (4) Decompress/uncompress on-the-fly. No storage changes needed — transformation happens per real-time request.

  4. What are the 4 types of Storage Gateway?

    Show answer

    (1) S3 File Gateway: NFS/SMB file shares backed by S3 — on-premises apps access S3 objects as files, (2) FSx File Gateway: local caching for FSx for Windows — on-premises SMB access with caching (SMB only, no NFS support), (3) Volume Gateway: iSCSI block storage backed by S3 — Stored (local primary + S3 backup) or Cached (S3 primary + local cache), (4) Tape Gateway: virtual tape library (VTL) backed by S3 Glacier — replaces physical tapes for backup software. Suited to hybrid cloud storage scenarios.

  5. A Lambda function generates a pre-signed URL with a 3-day expiration, but the URL dies after a few hours. Why, and how do you fix it?

    Show answer

    Lambda signs the URL with temporary credentials from its execution role (STS session token) → the URL expires when the session token expires (usually a few hours), regardless of the expiration you set. Fix: sign the URL with IAM user credentials (long-term access keys, stored in Secrets Manager) if you need the URL to live up to 7 days (the SigV4 maximum), or redesign so the client requests a new URL when needed (short-lived URLs are usually safer). This is a classic exam trap about pre-signed URLs.

  6. When should you use CloudFront Signed Cookies instead of an S3 Pre-signed URL?

    Show answer

    Use CloudFront Signed Cookies when you need to serve private content through a CDN and users need to access MANY files (e.g. HLS video streaming with hundreds of segment files, a members-only area of a website) — 1 cookie covers a whole resource pattern (/videos/*), takes advantage of edge caching, can restrict IP/date range via a custom policy, and works with custom origins too. Use an S3 Pre-signed URL when you need temporary direct access to 1 specific object in S3 — especially direct upload (PUT) from the client bypassing the app server, or sharing 1 download file for a limited time. Keyword "through CDN / many files" → CloudFront signed; "direct upload / 1 temporary object" → pre-signed.

  7. When should you choose gp3 over io2?

    Show answer

    gp3: baseline 3,000 IOPS/125 MBps, provision more independently of size up to 80,000 IOPS and 2,000 MiB/s, volumes up to 64 TiB (raised 09/2025) — ~20% cheaper than gp2 and enough for most workloads. io2 (Block Express): when you need consistent sub-ms latency, 99.999% durability, Multi-Attach, or > 80,000 IOPS on a single volume — demanding database tiers (SAP HANA, Oracle, SQL Server). Exam keyword: "most cost-effective, 10,000 IOPS" → gp3 (no need for io2); "sub-millisecond latency / 99.999% durability / > 80,000 IOPS single volume" → io2 Block Express.

  8. What are the constraints of EBS Multi-Attach?

    Show answer

    Only io1/io2, at most 16 instances, all in the same AZ, and it needs a cluster-aware file system (GFS2...) — regular ext4/XFS will get corrupted because writes are not coordinated. Multi-Attach is not a general shared file storage solution: to share files across AZs/many instances → EFS; Windows → FSx for Windows. This is a common exam trap.

  9. EFS Elastic vs Provisioned vs Bursting throughput?

    Show answer

    Bursting: throughput proportional to storage size (burst credits) — small file systems easily run out of credits. Provisioned: fixed at the level you pay for, for workloads that need high throughput but have little data. Elastic (the new default, recommended): scales automatically with the workload, pay-per-use — choose it when traffic is unpredictable, "least operational overhead". The IA class + Lifecycle management cuts the cost of rarely accessed files by ~92%.

  10. Which scenario calls for FSx for NetApp ONTAP instead of EFS?

Show answer

When you need: multi-protocol (NFS + SMB + iSCSI on the same data), NetApp features (SnapMirror replication from on-prem NetApp — the fastest migration path, snapshots, cloning, dedup/compression), or Windows + Linux clients accessing the same data. EFS is NFS/Linux only. FSx for OpenZFS for pure-Linux NFS needing low latency; FSx for Windows for SMB + AD; Lustre for HPC scratch + S3 integration.

  1. When do you choose DLM, and when AWS Backup?
Show answer

DLM: you only need to automatically create/keep/delete EBS snapshots or EBS-backed AMIs by tag + schedule — free, simple, "least effort" for EBS alone. AWS Backup: you need centralized multi-service backup (EBS, RDS, DynamoDB, EFS, FSx, S3...), cross-account/cross-region, or compliance — backup vault + Vault Lock (WORM), backup policies applied through Organizations. Exam: "automate EBS snapshot lifecycle" → DLM; "centralized/immutable backup across services and accounts" → AWS Backup.

  1. What problem does an EFS Access Point solve in a multi-tenant architecture?
Show answer

Each app/tenant mounts through its own access point: it is forced to a preconfigured POSIX UID/GID (ignoring the NFS client's identity — even root on the client is remapped) and is chrooted into its own root directory — isolating data on the same EFS without managing permissions on each client. Combine with a file system policy (IAM) with a condition on the Access Point ARN to force each role into its own access point only. Note: Lambda must mount EFS through an access point.

Hands-on Exercises

Part 1: S3 Advanced & Storage Gateway

  1. Multi-tenant S3 Access Point: create a bucket with 2 prefixes (/finance/, /analytics/), create 2 Access Points with policies limited by prefix and 1 AP restricted by VPC. Verify with the CLI (--endpoint via the AP alias) that each AP can only read its own prefix.

  2. S3 Object Lambda redaction: create an Object Lambda Access Point with a Lambda function that masks email/phone number fields in a JSON file on GET. Compare the response through a regular AP vs the Object Lambda AP — the original data in the bucket is unchanged.

  3. S3 Batch Operations: enable S3 Inventory for a bucket that already has a few hundred objects, and use the inventory report as the manifest to run a Batch Operations job that replaces tags in bulk. Review the completion report to understand how partial failures are handled.

Part 2: EBS, EFS, FSx Deep Dive

  1. gp2 → gp3 migration: create a 100GB gp2 volume, modify it to gp3 (elastic volume, no downtime), and raise IOPS to 6,000 independently of size — compare the monthly cost of the 2 configurations with the pricing calculator.

  2. EFS multi-AZ mount: create EFS + mount targets in 2 AZs, mount it from 2 EC2 instances in different AZs, write a file from one instance and read it from the other; enable a lifecycle policy that transitions to IA after 7 days.

  3. FSx for Lustre + S3: create an FSx for Lustre scratch file system linked to an S3 bucket, verify lazy-loading of objects from S3 through the file system, and export back (lfs hsm_archive) to S3.

References


Next lesson →