Course outline

5.4

EFS and Choosing Between EBS, EFS and Instance Store

A file system many instances share across AZs: modes, storage classes, lifecycle, and a decision table.

26 min Reading + animations

Tip: tap or hover any dotted-underlined term to see what it means.

By the end of this lesson you will be able to

  • Tell block, file and object storage apart, and say which AWS service gives each one.
  • Explain what Amazon EFS is: a managed NFS file system that many Linux instances in several Availability Zones mount at the same time.
  • Connect instances to EFS through mount targets and security groups, and fix a mount that hangs.
  • Choose between Regional and One Zone file systems, General Purpose and Max I/O, and the Elastic, Provisioned and Bursting throughput modes, using today’s AWS defaults.
  • Use the Standard, Infrequent Access and Archive storage classes with lifecycle management, and work out what it really saves.
  • Secure EFS with encryption, access points and IAM, protect it with AWS Backup and replication, and know when FSx is the answer instead.
  • Pick EBS, EFS or instance store (or FSx) from any exam scenario.

#Three ways to store data

Lessons 5.1 to 5.3 covered two kinds of disk an EC2 instance can use: EBS volumes and instance store. Both are block storage. Before adding EFS, it helps to have one clear model of the three ways storage can be offered.

Block storageFile storageObject storage
What you getA raw disk made of numbered blocks. The operating system formats it with its own file system (ext4 on Linux, the Windows file system on Windows).A ready-made file system with folders, file names, permissions and locks, reached over the network.A flat bucket of objects, each with a key, the data and metadata, reached through an HTTP API.
Who can use itNormally one instance at a timeMany instances at the same timeAny number of clients, from anywhere you allow
How you change dataRewrite any block in placeOpen, edit, append, lock, rename a fileReplace the whole object
AWS examplesEBS, instance storeEFS, FSxS3 (chapter on S3)
Typical useBoot volumes, databasesShared folders, web content, home directoriesBackups, media, data lakes, static websites

#What Amazon EFS is

Amazon Elastic File System (EFS) is a managed network file system. You create a file system, and EC2 instances mount it with the standard Linux NFS client, exactly like a shared drive on an office network. AWS runs the servers, the disks, the replication and the scaling.

  • Protocol: NFS version 4.0 and NFSv4.1, over TCP port 2049.
  • Shared: hundreds or thousands of instances can mount the same file system at once and read and write the same files. Containers and Lambda functions can mount it too, and on-premises servers can reach it over Site-to-Site VPN or Direct Connect.
  • Across AZs: a Regional file system stores its data redundantly in at least three Availability Zones, and instances in every AZ of the Region can use it at the same time.
  • Linux only: EFS works with Linux instances (and EC2 Mac instances). It is not supported on Windows. It behaves like a Linux file system: POSIX permissions (owner, group, read/write/execute), directories, and NFSv4 file locking.
  • Elastic size: there is no size to choose. The file system grows when you add files and shrinks when you delete them, up to petabytes. You never run out of space and never pay for empty space.
  • Pay per use: you pay for the GB you actually store each month (plus, depending on the throughput mode, for throughput). There is nothing to provision.

#How instances reach EFS: mount targets

An EFS file system lives at Region level, but instances live in subnets. The bridge between them is a mount target.

  1. One mount target per AZ

    A mount target is a network interface that EFS places in one subnet of your VPC, with a private IP from that subnet. A Regional file system can have one mount target in each AZ (never two in the same AZ). Create one in every AZ where instances will mount the file system; mount targets are free.

  2. A security group on the mount target

    Each mount target has one or more security groups. The rule that matters is inbound TCP 2049 (NFS) from the instances, best written with the instances’ security group as the source. The instances need outbound 2049 to the mount target, which the default “allow all outbound” rule already gives.

  3. Mount by name

    On the instance you mount the file system by its DNS name, fs-0abc1234.efs.us-east-1.amazonaws.com. Inside the VPC (with DNS resolution and DNS hostnames turned on) that name resolves to the mount target in the instance’s own AZ, so the traffic stays inside the AZ. The easiest way is the EFS mount helper (the amazon-efs-utils package): sudo mount -t efs -o tls fs-0abc1234:/ /mnt/efs.

Security groupDirectionProtocol and portSource / destination
Instances (sg-web)OutboundTCP 2049The mount target security group (default outbound already allows it)
Mount target (sg-efs)InboundTCP 2049sg-web (or the instances’ CIDR range)

Mounting through a mount target in another AZ works, but each GB that crosses the AZ boundary costs the usual cross-AZ data transfer ($0.01 per GB in each direction) and adds latency. Use the local mount target.

One file system, mounted from three AZs

EFS lives at Region level. Each AZ gets one mount target (a network interface in a subnet), and instances reach the file system through the mount target in their own AZ on NFS port 2049.

Scenario

Regionus-east-1
AZ a
AZ b
AZ c
web-1
web-2
web-3
mount target10.0.1.25
mount target10.0.2.25
mount target10.0.3.25
EFSfs-0abc1234
Step 1 of 4
1

One EFS file system and three web servers in three AZs. Each AZ has its own mount target with an IP from that AZ’s subnet.

#When the mount hangs

A blocked NFS port does not produce a neat “access denied”. A security group simply drops the packets, so the mount command waits and then fails with “Connection timed out”. Check, in this order:

SymptomLikely causeFix
mount hangs, then Connection timed outMount target security group has no inbound TCP 2049 from the instanceAdd inbound 2049 with the instance’s security group as the source
Same, but the security groups look rightA network ACL on either subnet blocks 2049, or the return traffic on high portsAllow 2049 and the ephemeral return ports in both NACLs (they are stateless)
Failed to resolve the file system nameNo mount target in the instance’s AZ, or DNS hostnames / DNS resolution off in the VPCCreate a mount target in that AZ; turn on DNS support; or mount a mount target by IP (paying cross-AZ)
unknown filesystem type 'efs'The mount helper is not installedInstall amazon-efs-utils (or use the plain NFS client with the NFSv4.1 options)
access denied by serverThe file system policy (IAM) refuses this client, for example because it did not use TLS or IAMMount with -o tls,iam and give the instance role the right EFS permissions

#What EFS costs, compared with EBS

EFS charges for the average GB stored per month, in each storage class. Prices below are for us-east-1 at the time of writing; other Regions differ, so always check the pricing page.

ItemPrice (us-east-1)
EFS Standard, Regional$0.30 per GB-month
EFS Standard, One Zone$0.16 per GB-month
EFS Infrequent Access (IA), Regional$0.016 per GB-month with Elastic throughput ($0.025 with Bursting or Provisioned)
EFS One Zone-IA$0.0133 per GB-month
EFS Archive (Regional only)$0.008 per GB-month
Reading from IA / tiering into IA$0.01 per GB
Reading from Archive / tiering into Archive$0.03 per GB
Elastic throughput$0.03 per GB read, $0.06 per GB written
Provisioned throughput$6.00 per MiB/s-month, above what Standard storage includes
For comparison: EBS gp3$0.08 per GB-month provisioned (lesson 5.2)

So per GB, EFS Standard costs almost four times as much as gp3. That is the note’s point that “EFS storage is a bit expensive”. But compare the whole picture:

  • With EBS you pay for the size you provision, used or not. A 1 TB gp3 volume holding 400 GB still costs $80.
  • With EFS you pay only for the GB actually stored, and nothing is ever full.
  • Three instances that each need the data would need three EBS volumes (and a way to keep them in sync). One EFS file system serves all of them.
  • With lifecycle management (below), cold files drop to IA or Archive and the average price per GB falls a long way.

#Regional or One Zone

When you create a file system, you choose its type:

Regional (recommended, default)One Zone
Where the data livesRedundantly across at least 3 AZsRedundantly inside one AZ
Survives an AZ failureYes, instances in the other AZs carry onNo, data is unavailable and could be lost if the AZ is damaged
Mount targetsOne per AZOne, in its own AZ (other AZs can reach it, paying cross-AZ)
Durability (designed for)11 nines11 nines (against disk, host and rack failures, not AZ loss)
Availability SLA (Standard)99.99%99.9%
Storage classesStandard, IA, ArchiveOne Zone, One Zone-IA (no Archive)
Price$0.30 per GB-month StandardAbout half: $0.16 per GB-month
Automatic backupsOn by default in the consoleOn by default in the console, CLI and API
Good forProduction, anything that must stay availableDev/test, analytics scratch, data you can rebuild or that has another copy

The notes call One Zone a “storage class”. In today’s console it is a file system type you pick at creation; it cannot be changed later. The two One Zone storage classes inside it are One Zone and One Zone-IA.

Regional vs One Zone when an AZ fails

A Regional file system stores data in at least three AZs. A One Zone file system stores it in one AZ, for about half the price.

Scenario

Regionus-east-1
AZ a
AZ b
AZ c
app-1
app-2
app-3
mount target
mount target
mount target
EFS Regional≥ 3 AZ
Step 1 of 3
1

A Regional file system with a mount target in each AZ. Every write is stored redundantly across several AZs before EFS confirms it.

#Performance: performance mode and throughput mode

Two separate settings decide how fast a file system is.

#Performance mode: always General Purpose

General PurposeMax I/O
StatusDefault and recommended for every file systemPrevious generation
LatencyLowest per operation (about 1 ms reads, about 2.7 ms writes on Regional)Higher per operation
RestrictionsNoneNot supported with Elastic throughput or One Zone file systems
Can it be changed later?No, chosen at creationNo

Older courses say “use Max I/O for big data and thousands of instances”. That advice is out of date: General Purpose with Elastic throughput now reaches hundreds of thousands of read operations per second (and more on request), so AWS recommends General Purpose everywhere. If an exam option still offers Max I/O for “highly parallel, can tolerate higher latency”, recognise it as the legacy answer.

#Throughput mode: how many MiB per second

ElasticProvisionedBursting
How throughput is setScales up and down automatically and instantly with demandYou set a number of MiB/s, independent of sizeScales with the size stored in Standard: 50 MiB/s baseline per TiB, burst to 100 MiB/s per TiB (minimum burst 100 MiB/s) using burst credits
You pay forGB transferred ($0.03 read, $0.06 written per GB)The MiB/s provisioned above the baseline your storage includes, every hourNothing extra; included in storage
Best forSpiky or unpredictable workloads, or average use of 5% of peak or lessKnown, steady throughput, or average use above about 5% of peakThroughput that naturally grows with the data
Default?Default in the console and recommendedNoDefault only through the CLI/API if you omit the setting
Watch outMonitor the transferred bytes so a runaway job does not run up the billAfter switching to Provisioned or raising it, you must wait 24 hours to lower it or switch awayA small file system has a tiny baseline; when credits run out it slows to that baseline

A few numbers to feel Bursting: 100 GiB in Standard earns about 5 MiB/s of write baseline (reads are metered at one third, so about 15 MiB/s). After a quiet day it has enough credits to burst at 100 MiB/s for about 72 minutes. File systems over 1 TiB can burst half of the time. Every file system gets at least 1 MiB/s.

The ceilings are much higher with Elastic. A Regional file system on Elastic throughput can read at 20–60 GiB/s and write at 1–5 GiB/s in total, depending on the Region, compared with 3–5 GiB/s reads on Bursting. A single client tops out at 1,500 MiB/s with the current EFS mount helper (500 MiB/s otherwise). Older slides quote 3 GiB/s reads and 1 GiB/s writes for Elastic; those limits have since been raised.

Throughput modes under a spike

A nightly job suddenly needs 100 MiB/s from a small file system that holds 100 GiB in Standard. Watch what each throughput mode does.

Scenario

Nightly job
EFS100 GiBcredits: full
Bill
baseline 5 MiB/s
Step 1 of 4
1

Bursting gives 50 MiB/s of baseline per TiB stored in Standard. 100 GiB earns only about 5 MiB/s of write baseline (reads are metered at a third, so about 15 MiB/s).

Self-checkQuestion

A media company stores 200 GiB of project files on EFS with Bursting throughput. Editors work normally all day, but a render job that starts every few days needs very high throughput for an unpredictable number of hours and then stops. Which change gives the best performance with the least management?

#Storage classes and lifecycle management

Most files are busy for a few days or weeks and then hardly ever opened again. EFS lets that cold data sit in cheaper storage classes without any change for the application.

Storage classDesigned forFirst-byte latencyPrice (us-east-1, Regional)Notes
StandardActive filesSub-millisecond (SSD)$0.30 per GB-monthAll new data lands here
Infrequent Access (IA)Files read a few times a quarterTens of milliseconds$0.016 (Elastic) or $0.025 per GB-month$0.01 per GB to read or to tier in; files billed at least 128 KiB
ArchiveFiles read a few times a year or lessTens of milliseconds$0.008 per GB-monthRegional and Elastic throughput only; $0.03 per GB to read or tier in; 90-day minimum storage charge
One ZoneActive files, One Zone typeSub-millisecond$0.16 per GB-month
One Zone-IACold files, One Zone typeTens of milliseconds$0.0133 per GB-month

#Lifecycle policies

Lifecycle management moves files between classes based on how long ago each file was last accessed in Standard. A file system has three lifecycle policies:

PolicyChoicesConsole default
Transition into IAAfter 1, 7, 14, 30, 60, 90, 180, 270 or 365 days without access, or never30 days
Transition into ArchiveAfter 1 to 365 days without access (same steps), or never90 days
Transition into StandardOn first access, or NoneNone: a file stays in IA or Archive when read

Details that exam questions and bills both care about:

  • EFS uses its own access timer, reset whenever a file in Standard is read or written. Metadata operations such as listing a directory or checking attributes do not count as access.
  • File names, ownership and the directory tree always stay in Standard, so browsing feels the same.
  • Writes to a file in IA or Archive go to Standard first and become eligible to move again 24 hours later.
  • With Transition into Standard = None, every read of a cold file pays the access charge and the higher latency. Set On first access for files that may become hot again (for example many small files read by an application), so the file moves back and later reads are fast and free of access charges.
  • A file system created through the CLI or API has no lifecycle policy until you add one with put-lifecycle-configuration.
  • Policies apply to the whole file system, not per folder.

Lifecycle: a file cools down, then is read again

Console defaults: into IA after 30 days without access, into Archive after 90 days, and no move back to Standard. Prices are us-east-1 per GB-month.

Scenario

App server
Standard$0.30invoice-0412.pdf
Lifecycleaccess timer
IA$0.016
Archive$0.008
write invoice-0412.pdf
Step 1 of 5
1

Every new file is written to Standard first: SSD-backed, sub-millisecond reads.

#Worked example: does IA really save 92%?

The notes say EFS-IA costs about 92% less than regular EFS. Check it against today’s us-east-1 prices:

  • IA on a Bursting or Provisioned file system: $0.025 ÷ $0.30 = 8.3%, so about 92% less. The note is right for that case.
  • IA on an Elastic file system (the console default): $0.016 ÷ $0.30 = 5.3%, so about 95% less.
  • Archive: $0.008 ÷ $0.30 = 2.7%, so about 97% less.

That is the price per GB. The saving on the bill is smaller, because hot data stays in Standard and cold data has access charges. Take a 1,000 GB Regional file system with Elastic throughput, where only 200 GB is touched in any given month:

Storage per monthNotes
No lifecycle1,000 × $0.30 = $300.00
IA after 30 days200 × $0.30 + 800 × $0.016 = $60.00 + $12.80 = $72.80One-time tiering 800 × $0.01 = $8. Reading 50 GB a month back from IA adds $0.50.
IA after 30 days, Archive after 90 days (500 GB untouched for 90+ days)200 × $0.30 + 300 × $0.016 + 500 × $0.008 = $60.00 + $4.80 + $4.00 = $68.80One-time tiering: 300 × $0.01 + 500 × $0.03 = $18. Archive reads cost $0.03 per GB.

So lifecycle cuts this bill by about 76%, not 92%, and the Archive step adds a little more. (Elastic throughput charges for reads and writes are the same in every row, so they are left out.) The more of your data is truly cold, the closer you get to the per-GB figure; on data that is touched every week, access and tiering charges can eat the saving.

#Security

#Encryption

  • At rest: EFS encrypts data and metadata with an AWS KMS key, the AWS managed key aws/elasticfilesystem or your own customer managed key. The console turns it on by default; through the CLI or API you must ask for it (--encrypted). It can be set only when the file system is created. To encrypt an existing unencrypted file system, create a new encrypted one and copy the data across.
  • In transit: mount with the EFS mount helper and the tls option. The helper wraps the NFS traffic in TLS 1.2 (still on port 2049). To make TLS compulsory, add a file system policy that denies access when aws:SecureTransport is false; the console offers this as “Enforce in-transit encryption for all clients”.

#Who may mount and what they may do

Three layers work together:

  1. Network: security groups and NACLs decide which machines can reach port 2049 at all.
  2. IAM: an EFS file system policy (a resource policy) plus the instance’s IAM role decide whether a client may mount, write, or act as root (ClientMount, ClientWrite, ClientRootAccess). Mount with -o tls,iam so the client presents its IAM identity. Ready-made options include preventing root access, enforcing read-only access and denying anonymous access.
  3. POSIX permissions: inside the file system, normal Linux owner, group and mode bits apply, just as on a local disk.

#Access points

An access point is an application-specific entry into the file system. It can:

  • force every request through it to use a fixed POSIX user ID and group ID, whatever the client claims;
  • expose only one directory as the root (for example /apps/billing), creating it with chosen owner and permissions if it does not exist;
  • be named in IAM policies, so the billing application’s role may mount only the billing access point.

Access points are the clean way to let several applications, containers or Lambda functions share one file system without seeing each other’s data.

#Protection: backups and replication

  • AWS Backup: daily incremental backups with 35-day retention under the default EFS backup plan. Automatic backups are on by default for file systems created in the console, and for One Zone file systems from any tool; for Regional file systems created by CLI/API, turn them on (--backup). Restores can bring back the whole file system or single files, to a new or existing file system, even in another AZ or Region. Restored files land in Standard.
  • EFS Replication: keeps a read-only copy of the file system in another Region (or the same Region), continuously, with a recovery point objective of 15 minutes for most file systems. In a disaster you fail over by deleting the replication configuration, which makes the copy writable, and point clients at it. The copy can be Regional or One Zone.

#EFS or FSx?

EFS is the general-purpose shared file system for Linux. Amazon FSx offers fully managed versions of other well-known file systems for the cases EFS does not cover. The details come in a later chapter; for now know the two that appear most:

NeedService
Shared files for Linux, many instances, several AZs, pay per useAmazon EFS
Shared files for Windows: SMB, Active Directory, Windows permissions (also usable from Linux over SMB)Amazon FSx for Windows File Server
HPC and machine learning: a parallel file system with very high throughput, often linked to an S3 bucketAmazon FSx for Lustre

#Choosing between EBS, EFS and instance store

#The full comparison

Instance storeEBSEFS
TypeLocal physical block storage on the hostNetwork block storageNetwork file storage (NFS)
PersistenceTemporary: lost on stop, hibernate, terminate or host failure; survives a reboot (lesson 5.3)Persistent until you delete the volume (root volumes are deleted on terminate by default, lesson 5.1)Persistent until you delete the files or the file system
Attach scopeOnly the one instance on that hostOne instance at a time (io1/io2 Multi-Attach: up to 16 Nitro instances, same AZ)Hundreds or thousands of instances at once
AZ scopeThe hostOne AZ; copy to another AZ only through a snapshotRegional: every AZ of the Region (One Zone: one AZ)
Operating systemsLinux and WindowsLinux and WindowsLinux only (Windows → FSx for Windows)
PerformanceHighest IOPS, lowest latency (local NVMe)Predictable; you choose type, size, IOPS and throughput (gp3, io2, st1, sc1)Network file system latency (about 1 ms reads); throughput Elastic, Provisioned or Bursting
SizeFixed by the instance typeYou provision it; grow it with Elastic VolumesGrows and shrinks automatically
CostIncluded in the instance pricePer GB provisioned (gp3 $0.08) plus extra IOPS/throughputPer GB stored ($0.30 Standard, much less in IA/Archive) plus throughput charges in Elastic/Provisioned
BackupNone built in; copy the data yourselfEBS snapshots, Data Lifecycle Manager, AWS BackupAWS Backup, EFS Replication
Best use casesCache, buffer, scratch, temporary data, replicated databases that rebuild a nodeBoot volumes, databases, any single-instance application dataWordPress / CMS content, shared directories, home directories, web serving fleets, container and Lambda shared storage

Which storage fits?

Answer four questions about the data. The answer changes as you click, with the reason and the words an exam question would use.

1. What is it for?

2. Who uses it at the same time?

3. Operating system

4. Must it survive a stop, terminate or host failure?

Amazon EFS (Regional)

Many Linux instances in several AZs reading and writing the same files: a Regional EFS file system with a mount target in each AZ. Add lifecycle management to IA and Archive for files that go cold.

Exam keywords: shared file system, concurrent access, multiple AZs, Linux, POSIX, WordPress / CMS, home directories

#How to choose

  1. Windows server sharing files?

    Shared files for Windows → FSx for Windows File Server. EFS does not support Windows.

  2. Several instances need the same files at the same time?

    Yes, Linux → EFS (Regional for production; One Zone for dev/test). If it is HPC on data in S3 → FSx for Lustre.

  3. Can the data be lost when the instance stops or the host fails?

    Yes, it is a cache, buffer or scratch space you can rebuild, and you need the highest IOPS → instance store (on an instance type that has it).

  4. Otherwise

    One instance, data must persist, boot volume or database → EBS (gp3 by default, io2 for the highest sustained IOPS, st1/sc1 for cheap sequential data). Several instances in one AZ sharing one block device with a cluster-aware application → io2 Multi-Attach.

#Worked exam scenarios

ScenarioAnswerWhy
A WordPress site runs on an Auto Scaling group across three AZs; uploaded images must be visible on every serverEFS (Regional)Many Linux instances, several AZs, shared files
Fifty Windows application servers need a shared drive that uses the company’s Active DirectoryFSx for Windows File ServerWindows, SMB, Active Directory; EFS is Linux only
A self-managed database on one instance needs consistent low latency and 40,000 IOPSEBS io2 (or gp3 if enough)Block storage for one instance; EFS adds network file system latency
A NoSQL cluster keeps three copies of every item and needs the fastest possible local diskInstance storeData is replicated by the application; losing one node’s disk is acceptable
Cost-optimise a shared document store where most files are not opened after a few weeksEFS lifecycle to IA (and Archive)Pay a fraction for cold files, same paths for the application
A shared Linux workload has unpredictable bursts of very high throughput, independent of file system sizeEFS Elastic throughputScales instantly, pay per GB transferred
Developers need the cheapest shared Linux file system for a test environment; losing it in an AZ outage is acceptableEFS One Zone (with One Zone-IA)About half the price; backups are on by default
An HPC job needs a high-performance parallel file system over data stored in S3FSx for LustreBuilt for HPC throughput and S3 integration
Lambda functions need a shared, persistent directory for large model filesEFS through an access pointLambda can mount EFS; access points pin the directory and POSIX identity
A database instance in us-east-1a fails over to a standby in us-east-1b, and the standby must see the same block volumeNot EBS: replicate at the database level (or use a managed Multi-AZ database)An EBS volume cannot attach across AZs

Self-checkQuestion

An e-commerce application runs on Linux EC2 instances in an Auto Scaling group across three Availability Zones. Product images uploaded by staff must be immediately available to every instance, and the storage must stay available if one AZ fails. What should a solutions architect use?

#How EFS is used in system design

  • Web fleets behind a load balancer: WordPress, Drupal and other CMS sites put uploads, themes and plugins on EFS so any instance can serve any request and Auto Scaling can add or remove instances freely.
  • Shared home directories and development environments for Linux users.
  • Containers and serverless: tasks and Lambda functions that come and go need state that outlives them; an access point per application keeps them apart.
  • Content and media workflows: several processing servers read and write the same project folders.
  • Machine learning: training and inference nodes load the same datasets and models.

Where EFS is the wrong tool:

  • Databases with heavy small random writes: every operation crosses the network to a distributed file system, so latency is higher than on EBS. Use EBS (or a managed database).
  • Windows: use FSx for Windows File Server.
  • Archives and public assets served over HTTP: S3 is far cheaper per GB and scales to any number of clients.
  • Scratch space that needs the very lowest latency: instance store.

#Try it yourself

# 1. Security groups: instances (sg-web) and mount targets (sg-efs, inbound NFS from sg-web)
aws ec2 create-security-group --group-name sg-efs --description "EFS mount targets" --vpc-id $VPC
aws ec2 authorize-security-group-ingress --group-id $SG_EFS \
  --protocol tcp --port 2049 --source-group $SG_WEB

# 2. A Regional, encrypted file system with Elastic throughput and automatic backups
FS=$(aws efs create-file-system --creation-token shared-web-1 \
  --performance-mode generalPurpose --throughput-mode elastic \
  --encrypted --backup --tags Key=Name,Value=shared-web \
  --query FileSystemId --output text)
aws efs describe-file-systems --file-system-id $FS \
  --query "FileSystems[0].[LifeCycleState,ThroughputMode,PerformanceMode,Encrypted]"

# 3. One mount target per AZ (one subnet in each)
for SUBNET in $SUBNET_A $SUBNET_B $SUBNET_C; do
  aws efs create-mount-target --file-system-id $FS --subnet-id $SUBNET --security-groups $SG_EFS
done
aws efs describe-mount-targets --file-system-id $FS \
  --query "MountTargets[].[AvailabilityZoneName,IpAddress,LifeCycleState]"

# 4. Lifecycle: IA after 30 days, Archive after 90, back to Standard on first access
aws efs put-lifecycle-configuration --file-system-id $FS --lifecycle-policies \
  TransitionToIA=AFTER_30_DAYS TransitionToArchive=AFTER_90_DAYS \
  TransitionToPrimaryStorageClass=AFTER_1_ACCESS

# 5. An access point for one application: fixed POSIX identity and its own directory
aws efs create-access-point --file-system-id $FS \
  --posix-user Uid=1001,Gid=1001 \
  --root-directory "Path=/apps/web,CreationInfo={OwnerUid=1001,OwnerGid=1001,Permissions=750}"

# 6. On an instance (Amazon Linux 2023): install the mount helper and mount with TLS
sudo dnf install -y amazon-efs-utils
sudo mkdir -p /mnt/efs
sudo mount -t efs -o tls fs-0abc1234:/ /mnt/efs
df -h /mnt/efs                     # size shows as 8.0E: there is no fixed size
echo "fs-0abc1234:/ /mnt/efs efs _netdev,tls 0 0" | sudo tee -a /etc/fstab   # remount at boot
#    Through an access point, with IAM authorisation:
sudo mount -t efs -o tls,iam,accesspoint=fsap-0123456789abcdef0 fs-0abc1234:/ /mnt/web

# 7. Troubleshoot a hanging mount: can the instance reach the mount target on 2049?
nc -zv -w 3 10.0.1.25 2049        # times out → check sg-efs inbound 2049 and the NACLs

#Summary

Key takeaways

  • Block storage (EBS, instance store) is a raw disk for one instance; file storage (EFS, FSx) is a shared file system for many; object storage (S3) is whole objects over HTTP.
  • EFS is a managed NFSv4.1 file system for Linux. Hundreds or thousands of instances, in every AZ of the Region, mount it at once. It grows and shrinks automatically, and you pay per GB stored.
  • Instances reach it through one mount target per AZ. The mount target’s security group must allow inbound TCP 2049 from the instances; otherwise the mount hangs and times out.
  • Regional (≥ 3 AZs, recommended) vs One Zone (one AZ, about half the price, no Archive, backups on by default, lost with its AZ).
  • Performance mode: General Purpose always; Max I/O is legacy and not allowed with Elastic or One Zone.
  • Throughput: Elastic (console default, spiky and unpredictable, pay per GB transferred), Provisioned (set MiB/s, pay for it), Bursting (scales with size, burst credits, API default).
  • Storage classes: Standard, IA, Archive (plus One Zone and One Zone-IA). Lifecycle moves files after N days without access (console: IA 30, Archive 90) and, if set, back on first access. IA and Archive have per-GB access charges.
  • IA is about 92% cheaper per GB on Bursting/Provisioned file systems and about 95% on Elastic; the real bill saving depends on how much data is truly cold.
  • Encryption at rest with KMS is chosen at creation only; in transit uses the mount helper’s TLS option. Access points and IAM control who mounts what. AWS Backup and EFS Replication protect the data.
  • Windows → FSx for Windows File Server; HPC → FSx for Lustre; one instance, persistent block → EBS; temporary, fastest → instance store; shared Linux files across AZs → EFS.