Sub topic 10
Storage Scope: What Is Regional and What Is Zonal
This chapter assumes you know what an Availability Zone (AZ) is, how a VPC spans a Region, and the basics of EC2, EBS, and S3. The question for each storage service is whether its data lives in one AZ or is replicated across several. If you assume the wrong scope, a single AZ failure can take your data offline.
Why scope matters
A storage service has a scope: zonal (data lives in one AZ) or regional (data is stored redundantly across multiple AZs in a Region). A zonal service is a failure domain by itself. If its AZ is impaired, the data is unavailable until the AZ recovers, even though the Region is healthy.
Scope of common storage services
| Service | Default scope | What to know |
|---|---|---|
| Amazon S3 (Standard, Standard-IA, Glacier Instant Retrieval) | Regional | Objects are stored across at least three AZs. |
| S3 One Zone-IA | Zonal | Stored in one AZ. Cheaper, but lost if that AZ is destroyed. |
| Amazon EFS (Regional file systems) | Regional | Mount targets are zonal, one per AZ. |
| Amazon EFS One Zone | Zonal | Data lives in one AZ. |
| Amazon EBS volume | Zonal | Attaches only to instances in the same AZ. |
| EC2 instance store | Zonal | Tied to the host. Data is lost when the instance stops or fails. |
| DynamoDB | Regional | Replicated across multiple AZs automatically. |
EBS: zonal by design
An EBS volume is replicated inside its AZ, which protects against hardware failure. It does not protect against the loss of the AZ. A volume in one AZ cannot be attached to an instance in another.
To get data out of an AZ, take a snapshot. Snapshots are stored in S3 and are regional, so you can restore one into any AZ in the Region.
VOLUME_ID=vol-0123456789abcdef0
SNAPSHOT_ID=$(aws ec2 create-snapshot \
--volume-id "$VOLUME_ID" \
--description "Cross-AZ recovery copy" \
--query SnapshotId --output text)
aws ec2 wait snapshot-completed --snapshot-ids "$SNAPSHOT_ID"
aws ec2 create-volume \
--snapshot-id "$SNAPSHOT_ID" \
--availability-zone us-east-1b \
--volume-type gp3Snapshots run on a schedule, so you lose any writes after the last one. For a stateless tier this is fine. For state that must survive an AZ loss, move the data to a regional service.
EFS: regional data, zonal mount targets
A Regional EFS file system stores data across AZs. You reach it through mount targets, and each mount target sits in one AZ. Create one in every AZ where you run compute. Instances should mount through the mount target in their own AZ, which avoids cross-AZ traffic and avoids depending on another zone.
aws efs create-mount-target \
--file-system-id fs-0123456789abcdef0 \
--subnet-id subnet-0aaa1111bbbb2222c \
--security-groups sg-0123456789abcdef0Repeat the command with a subnet from each additional AZ.
Choosing a scope
Common errors
- Putting application state on an EBS volume and assuming the Auto Scaling group will recover it in another AZ. A replacement instance in a new AZ gets a new, empty volume.
- Using S3 One Zone-IA or EFS One Zone for data you cannot recreate.
- Creating an EFS mount target in only one AZ, so instances in other AZs cannot mount the file system, or must reach it across zones.
- Treating instance store as durable.
Exercise
An application writes uploaded files to an EBS volume on a single EC2 instance in us-east-1a. The AZ becomes unavailable. Why can't you attach that volume to a new instance in us-east-1b, and what two changes would let the files survive an AZ loss?
Show answer
An EBS volume is zonal and can attach only to instances in its own AZ. The files survive an AZ loss if you store them in a regional service such as S3 or Regional EFS (with mount targets in each AZ), or if you take regular EBS snapshots, which are regional and can be restored into us-east-1b, accepting that you lose writes made after the last snapshot.