Sub topic 2
Regions, Availability Zones, and AZ IDs
This chapter assumes you know what an AWS Region, a VPC, and an EC2 instance are, and that you can run AWS CLI commands. It builds the working model of Regions and Availability Zones (AZs) that later chapters use when they spread subnets, instances, and databases across zones.
The hierarchy: Region, AZ, data center
A Region is a geographic area, such as us-east-1 (N. Virginia) or eu-west-1 (Ireland). Regions are isolated from each other by design. Most services keep their data and control plane within one Region, and your resources do not move between Regions unless you copy or replicate them.
An Availability Zone is one or more discrete data centers inside a Region. Each has its own power, cooling, and physical security. AZs in a Region are connected by high-bandwidth, low-latency private fiber, and they are placed far enough apart that a fire, flood, or power failure is unlikely to affect two of them at once. They are still close enough for synchronous replication, which is why RDS Multi-AZ and similar features can work across them.
| Level | What it is | Typical failure it contains | Who picks it |
|---|---|---|---|
| Region | Group of AZs in one geography | Region-wide service event, regulatory scope | You, per resource or API call |
| Availability Zone | One or more data centers with independent power and networking | Power loss, cooling failure, local network fault | You, per subnet or per instance |
| Data center | A building inside an AZ | Not visible to you | AWS |
Each Region has at least three AZs, with a few exceptions. This is why many designs use three zones: losing one still leaves two.
Regional and zonal scope
Every AWS resource has a scope. Knowing it tells you what survives an AZ failure.
- Zonal resources live in exactly one AZ. Examples are a subnet, an EC2 instance, an EBS volume, and a NAT gateway. If that AZ is impaired, the resource is impaired.
- Regional resources span the Region. A VPC, an S3 bucket, an internet gateway, and an Application Load Balancer are regional in scope. The AWS-managed service spreads its own capacity across AZs for you.
- Global or edge resources, such as IAM and Route 53 hosted zones, are not tied to a Region you choose.
A common mistake is to treat a regional-looking name as proof of resilience. An ALB is regional, but it only uses the AZs whose subnets you attach to it. If you attach one subnet, you have one zone of load balancer capacity. Later chapters return to this point for each service.
AZ names and AZ IDs
When you create a subnet, you choose an AZ by name, such as us-east-1a. The name is a label, not a fixed physical location. To spread demand evenly, AWS maps the names to physical zones separately for each account. Your us-east-1a can be a different physical zone than another account's us-east-1a.
The AZ ID, such as use1-az1, identifies the same physical zone in every account. Use AZ IDs when you must be sure two things are in the same place or in different places. Typical cases:
- Two accounts share a resource, such as a VPC subnet through AWS Resource Access Manager (RAM) or a PrivateLink endpoint service, and you want traffic to stay in one zone to avoid cross-AZ data charges and latency.
- A support case or AWS Health event names an AZ ID, and you need to know which of your resources it affects.
- You are checking that a service's supported zones match your subnets.
List the mapping for your account and current Region:
aws ec2 describe-availability-zones \
--query 'AvailabilityZones[].[ZoneName,ZoneId]' \
--output tableThe table shows each name next to its ID. Run the command in two accounts and compare. The ZoneName column may differ for the same ZoneId, while the ZoneId column stays consistent.
Zones you may not see
describe-availability-zones returns only the zones available to your account in the current Region. Some newer zones, Local Zones, and Wavelength Zones must be enabled first. You can see them with --all-availability-zones, which includes an OptInStatus field. Local Zones and Wavelength Zones are extensions placed near population centers or carrier networks. They are not substitutes for a normal AZ in a failure-domain design, because their parent Region still provides the control plane and many dependencies.
Failure domains in practice
A failure domain is the set of resources that can fail together because of one cause. The AZ is the main failure domain you design for. Several kinds of events map to it:
- A power or cooling failure in one AZ's facilities.
- A network fault that isolates one AZ from the rest.
- A deployment or configuration problem scoped to one zone, such as a bad subnet route table.
- A capacity shortage for one instance type in one AZ. This is not an outage, but it can stop you from launching replacements.
An AZ is not a failure domain for everything. A regional service event, a bad IAM policy you deploy to every zone, or a corrupted database that you replicate to every zone will cross AZ boundaries. Chapter 3 treats failure domains and single points of failure in detail. For now, remember that multi-AZ protects against zonal infrastructure failure, not against mistakes that you copy everywhere.
How AZ choice shows up in your resources
You select AZs indirectly in most services:
- VPC subnets are bound to one AZ at creation. The subnet's AZ decides where instances, NAT gateways, and network interfaces in it run.
- Load balancers use the subnets you attach, one per AZ, and run nodes in those zones.
- Auto Scaling groups use the subnets in
VPCZoneIdentifierto choose zones, and balance instances across them. - RDS takes a subnet group that covers at least two AZs, and Multi-AZ places the standby in a different one.
- EBS volumes are created in one AZ and can attach only to instances in that same AZ.
Because subnets are the handle for zone selection, a well-organized naming scheme helps. Tag each subnet with its AZ ID, not only its name, so that operations in several accounts line up.
You can read a subnet's zone and zone ID directly:
aws ec2 describe-subnets \
--query 'Subnets[].[SubnetId,AvailabilityZone,AvailabilityZoneId,CidrBlock]' \
--output tableChoosing how many AZs
Two AZs is the minimum for surviving one zone loss, but capacity matters as much as count. If two zones each carry 50 percent of the load and one fails, the survivor must absorb 100 percent. With three zones at 33 percent each, losing one means the other two must each carry 50 percent, so you provision about 150 percent of peak capacity in total, not 200 percent. Chapter 12 returns to this under static stability.
| Zones used | Load per zone (normal) | Load per surviving zone after one loss | Total capacity needed to carry peak |
|---|---|---|---|
| 2 | 50% | 100% | 200% of peak |
| 3 | 33% | 50% | 150% of peak |
| 4 | 25% | 33% | 133% of peak |
More zones lower the cost of headroom but add subnets, endpoints, and cross-zone traffic to manage. Some regions offer fewer than three zones, and some services or instance types are available only in a subset. Check support before you design.
Common errors
- Hard-coding zone names. A template that says
us-east-1acan fail in another account or Region. UseFn::GetAZsor a parameter, and select by AZ ID when you need a specific physical zone. - Assuming a regional service covers unused zones. Attach subnets in every AZ you want an ALB or endpoint to serve.
- Ignoring zonal resource scope. An EBS volume or NAT gateway in one AZ is a single point of failure for anything that depends on it.
- Comparing zone names across accounts. Compare AZ IDs.
- Counting zones but not capacity. Three subnets with one instance each does not survive the loss of a zone under load.
Exercise
Account A and Account B both see a subnet in us-east-1a. A shared service in Account A is in one zone, and you want to place your Account B workload in the same physical zone to avoid cross-AZ charges. What do you compare, and why not the zone name?
Show answer
Compare the AZ ID (for example use1-az2) from aws ec2 describe-availability-zones in each account. AWS maps zone names such as us-east-1a to physical zones separately for each account, so the same name can be different physical zones. The AZ ID refers to the same physical zone in every account. Then pick the Account B subnet whose AZ ID matches the one Account A uses.
Exercise
A team attaches one subnet in us-east-1a to an Application Load Balancer and says the design is multi-AZ because the ALB is a regional service. What is wrong, and what is the fix?
Show answer
The ALB runs nodes only in the AZs of the subnets attached to it, so with one subnet it has capacity in one zone and that zone is a single point of failure. Attach at least one subnet in a second AZ, and also place targets in both zones.