Sub topic 8
AZ names versus AZ IDs
This chapter assumes you can run AWS CLI commands, know what a VPC and a subnet are, and have read the earlier chapter on Availability Zones. It covers why us-east-1a in your account may not be the same physical zone as us-east-1a in a colleague's account, and what to do about it.
Two identifiers for one zone
Every Availability Zone (AZ) has two identifiers.
- AZ name is the label you see most often, such as
us-east-1a. It is the Region code plus a letter. - AZ ID is a fixed identifier for the physical zone, such as
use1-az1. It has a Region abbreviation,az, and a number.
The AZ ID means the same thing in every AWS account. The AZ name does not. AWS maps names to physical zones separately for each account. This spreads load, because if everyone's a pointed to the same zone, that zone would fill up first.
The mapping is fixed for an account. It does not change over time and you cannot edit it. Two accounts can both have an a zone in us-east-1 that are different physical locations.
| Account | Zone name | Zone ID |
|---|---|---|
| Account A | us-east-1a | use1-az1 |
| Account A | us-east-1b | use1-az2 |
| Account B | us-east-1a | use1-az2 |
| Account B | us-east-1b | use1-az1 |
The table is an illustration. Your real mappings will differ, so check your own accounts.
Looking up your own mapping
The describe-availability-zones command returns both identifiers for the Region you query:
aws ec2 describe-availability-zones --region us-east-1 \
--query "AvailabilityZones[].[ZoneName,ZoneId,State,ZoneType]" \
--output tableEach row pairs a name with its ID, plus the zone's state and type. For standard AZs, ZoneType is availability-zone. Local Zones and Wavelength Zones also appear when you have enabled them. Their IDs have a longer form, such as use1-bos1-az1.
Run the command once in each account that takes part in a shared design. Save the output next to your architecture notes. The mapping never changes, so the record stays valid.
You can get the same data from boto3. This version filters to standard AZs:
import boto3
ec2 = boto3.client("ec2", region_name="us-east-1")
response = ec2.describe_availability_zones(
Filters=[{"Name": "zone-type", "Values": ["availability-zone"]}]
)
for az in response["AvailabilityZones"]:
print(az["ZoneName"], az["ZoneId"], az["State"])The number of AZs a Region exposes can vary between accounts. Do not hardcode a list of letters or a count. Query the API and use what it returns.
Why the difference matters
For a single account in a single Region, names are fine. Name-to-ID mapping starts to matter when two accounts need to agree on a physical location. These are the common cases.
Shared subnets
With VPC sharing through AWS Resource Access Manager (RAM), one account owns a subnet and shares it with others. A subnet lives in one physical zone. Participant accounts see that subnet labelled with the zone name from the owner's mapping or their own, depending on where they look. Two teams discussing "subnet in us-east-1a" may mean different zones. Agree on the AZ ID instead. The owner's subnet details show the zone ID, so you can confirm placement.
Services exposed to other accounts
A provider exposes a service through AWS PrivateLink. Consumers create interface endpoints in their own VPCs. A consumer endpoint can only use AZs where the provider's service is available. Matching those AZs by name across accounts can pick the wrong zones. Compare by AZ ID. The provider can list the zones it supports, and the consumer can compare them to the IDs in its own account.
Data transfer cost and latency
Traffic between different AZs in a Region is billed, usually at a small per-GB rate in each direction. Check the current pricing page for the exact figure. Traffic that stays inside one AZ avoids this charge. If a consumer in Account B wants to talk to a provider in Account A without paying cross-AZ rates, both must sit in the same physical zone. "Both in us-east-1a" does not guarantee that. "Both in use1-az1" does.
Zonal reservations and capacity
Zonal Reserved Instances and On-Demand Capacity Reservations are tied to a zone as your account names it. Because the mapping is per account, a reservation for us-east-1a in one account covers a different physical zone than in another. Reservation sharing across an AWS Organization is therefore easy to misread. The match happens against the physical zone, so check IDs before you assume a reservation will be used.
Capacity and instance type availability
Not every AZ offers every instance type. If a launch fails with InsufficientInstanceCapacity, or a type is missing in some zone, do not retry the same name. Ask which zones offer the type, using IDs:
aws ec2 describe-instance-type-offerings \
--location-type availability-zone-id \
--filters Name=instance-type,Values=m7g.large \
--region us-east-1 \
--query "InstanceTypeOfferings[].Location" \
--output textThe output is a list of AZ IDs. Look each one up in the mapping for your account to learn the matching name.
Placing resources by AZ ID
Many EC2 calls accept either a name or an ID. When the physical location matters, use the ID. This command creates a subnet in a specific physical zone:
aws ec2 create-subnet \
--vpc-id vpc-0123456789abcdef0 \
--cidr-block 10.0.1.0/24 \
--availability-zone-id use1-az1The VPC ID is a placeholder. Replace it with a VPC from your account.
Pass either --availability-zone or --availability-zone-id, not both. The API treats them as alternative ways to name the same thing and rejects a call that sets both.
Infrastructure as code tools follow the same idea. CloudFormation's AWS::EC2::Subnet accepts AvailabilityZoneId, and Terraform's aws_subnet accepts availability_zone_id. Check the current documentation of your tool and version for the exact property name. In CloudFormation, Fn::GetAZs returns names, so it is the wrong source of values when you need identical physical zones across accounts.
A workable routine
- For each account in the design, run
describe-availability-zonesin the Region and save the name-to-ID table. - Decide the target physical zones by ID, for example
use1-az1anduse1-az2. - Translate each ID into that account's name only where an API accepts nothing else, such as a zonal reservation.
- Pass the ID directly wherever the API supports it.
- Write IDs, not names, in architecture documents and runbooks.
Common errors
- Assuming
ais the same everywhere. A cross-account design that lists "subnet inus-east-1a" for both accounts can silently place the two in different zones. You pay cross-AZ transfer and add latency, and nothing reports an error. - Copying a template between accounts with hardcoded names. The template deploys, but the physical zones differ from the original account. If you moved the template to match a reservation or a partner's zone, the match is lost.
- Using
--availability-zoneand--availability-zone-idtogether. The call fails. Pick one. - Reading a zone's name from a screenshot or chat message. A name is only meaningful with its account. Ask for the ID.
- Hardcoding a list of AZs. The set a Region exposes can differ between accounts, and AZs have a state. Query the API and filter on
StateandZoneType.
Summary of when to use which
| Situation | Use |
|---|---|
| One account, spread across zones for availability | Names or IDs, either works |
| Shared subnets across accounts | IDs |
| PrivateLink provider and consumer alignment | IDs |
| Avoiding cross-AZ data transfer between accounts | IDs |
| Zonal reservations and capacity reservations | Name from the account that owns the reservation, confirmed with the ID |
| Documentation and runbooks | IDs |
Exercise
Account A's us-east-1a maps to use1-az1. Account B owns a service and wants Account A's workload to sit in the same physical zone as its own us-east-1a to avoid cross-AZ data transfer charges. Account B's us-east-1a maps to use1-az2. Which AZ name should Account A use, and which command would you run to confirm it?
Show answer
Account A should use whichever of its names maps to use1-az2, which is not us-east-1a. Run aws ec2 describe-availability-zones --region us-east-1 --query "AvailabilityZones[].[ZoneName,ZoneId]" --output table in Account A and read the name beside use1-az2. Better still, create the subnet with --availability-zone-id use1-az2 so no name lookup is needed.
Exercise
A teammate says a launch failed with InsufficientInstanceCapacity in us-east-1b in your account, and suggests trying us-east-1b in the other account. Why is that suggestion unreliable, and what would you check instead?
Show answer
The name us-east-1b can refer to a different physical zone in the other account, so the capacity situation may differ. Check which AZ IDs offer the instance type with aws ec2 describe-instance-type-offerings --location-type availability-zone-id, then pick a zone by ID in each account.