Sub topic 1
How AWS is laid out: Regions, AZs, and the edge
Prerequisites
This chapter assumes the following:
- You have an AWS account, or you plan to create one. Nothing here needs a paid resource.
- You know what a virtual server and object storage are in general terms.
- You can run commands in a terminal. The examples use the AWS CLI version 2 and Python with boto3.
- You know roughly what a network and an IP address are.
Later chapters cover Regions, Availability Zones, resource scope, and cost in more detail. This chapter gives you the overall map so that those chapters have a place to attach.
The three layers
AWS global infrastructure has three layers that matter for everyday work:
- Regions are separate geographic areas, such as
us-east-1(N. Virginia) oreu-west-1(Ireland). - Availability Zones (AZs) are one or more discrete data centers inside a Region. Each has its own power, cooling, and networking.
- Edge locations are sites close to end users. AWS uses them for content delivery, DNS, and traffic acceleration. You do not launch servers in them the way you do in a Region.
Most of what you build runs in a Region and its AZs. The edge extends your reach toward users.
Regions: isolated geographic areas
A Region is a physical area of the world where AWS runs a cluster of data centers. Each Region is independent of the others. This isolation is deliberate and has practical consequences:
- Fault isolation. A problem in one Region does not normally spread to another.
- Data stays put. Your data is stored in the Region you choose. AWS does not move it to another Region unless you configure replication or copy it yourself. This is the basis for data residency and compliance decisions.
- Separate resource namespaces. An EC2 instance in
us-east-1does not appear when you look ateu-west-1. You must work in the Region where the resource lives. - Separate service endpoints. Each Region has its own API endpoint, for example
ec2.us-east-1.amazonaws.comandec2.eu-west-1.amazonaws.com.
Region names have a code such as eu-west-1, which combines a geography (eu-west) with a number. The console also shows a friendly name such as Europe (Ireland).
Not every service or feature is available in every Region. New services usually launch in a small number of Regions first. Chapter 5 of this tutorial covers how to weigh this when choosing.
Seeing your Regions
You can list the Regions enabled for your account with the CLI:
aws ec2 describe-regions --query "Regions[].RegionName" --output textBy default this returns only the Regions that are enabled for your account. Some newer Regions are opt-in and stay hidden until you enable them. To see those, add --all-regions and filter on OptInStatus:
aws ec2 describe-regions --all-regions \
--query "Regions[?OptInStatus=='not-opted-in'].RegionName" \
--output textThe output is the list of opt-in Regions you have not yet enabled. An empty result means you have none outstanding. Chapter 7 covers how to enable one.
Availability Zones: isolated locations within a Region
An Availability Zone is one or more data centers in a Region, with independent power, cooling, and physical security. AZs in a Region are connected by a low-latency, high-bandwidth private network. They are placed far enough apart that a fire, flood, or power failure at one site is unlikely to affect another, yet close enough for fast synchronous replication between them.
Most Regions have three or more AZs. Some older or smaller Regions may have fewer. AZ names are the Region code plus a letter, such as us-east-1a, us-east-1b, and us-east-1c.
Seeing your AZs
The following command prints each AZ with its name, its ID, its state, and its zone type:
aws ec2 describe-availability-zones --region us-east-1 \
--query "AvailabilityZones[].[ZoneName,ZoneId,State,ZoneType]" \
--output tableYou will see two identifiers for each zone. The name, such as us-east-1a, is what most console screens and templates show. The ID, such as use1-az1, identifies the physical zone. The two do not always line up between accounts: AWS maps names to IDs separately for each account, so your us-east-1a may be a different physical zone from someone else's us-east-1a. This matters when two accounts need to share a zone, and Chapter 8 covers it. For now, remember that the ID is the stable identifier.
You can run the same query from Python with boto3. This version keeps only standard AZs and leaves out Local Zones and Wavelength Zones, which are covered below:
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"])How Regions and AZs relate
The relationship is strictly hierarchical. Every AZ belongs to exactly one Region, and every Region contains several AZs. You never choose an AZ without first choosing a Region.
The table below compares the two as units of design.
| Property | Region | Availability Zone |
|---|---|---|
| What it is | A geographic area | One or more data centers inside a Region |
| Isolation from peers | Very strong. Independent by design | Strong, but linked by a fast private network |
| Typical count per account view | Many Regions to choose from | Three or more per Region |
| Protects against | Regional outage, legal and residency requirements | Failure of a single data center site |
| Latency between peers | Tens to hundreds of milliseconds across continents | Single-digit milliseconds within a Region |
| Example name | `eu-west-1` | `eu-west-1b` |
The latency row shows why the split exists. You can replicate data synchronously across AZs because they are close. Across Regions you usually replicate asynchronously, because distance adds delay.
Edge locations and extended zones
Beyond Regions and AZs, AWS operates infrastructure closer to users. These pieces do not replace Regions. They extend them.
- Edge locations host services such as Amazon CloudFront (content delivery) and Amazon Route 53 (DNS). They cache content and answer requests near the user, then forward to a Region when needed.
- Local Zones put selected compute, storage, and database services near large population or industry centers. A Local Zone is attached to a parent Region and appears in the AZ list with a different zone type.
- Wavelength Zones embed AWS services within telecommunications providers' 5G networks, to cut latency for mobile applications.
You can tell these apart by the ZoneType column in the earlier CLI output. A standard AZ shows availability-zone, while the others show other values. This is why the boto3 example filters on zone-type: without the filter, extended zones can appear in the same list and surprise you.
Chapter 10 returns to these in detail.
Where your resources live
A useful first rule: nearly every resource you create has a place. Some live in a Region, some in a single AZ, and a few are global. Seeing the layout now helps you read the console correctly.
- A regional resource, such as a VPC or an S3 bucket's data, appears only when the console is set to its Region.
- A zonal resource, such as an EC2 instance or an EBS volume, sits in one AZ inside a Region.
- A global resource, such as an IAM user, is visible no matter which Region you select.
Chapter 4 covers this classification fully. The common beginner mistake is to create something, switch Region in the console, and conclude the resource has disappeared. It has not. You are looking in a different Region.
Setting the Region you work in
The CLI and SDKs need to know which Region to talk to. One way is an environment variable:
export AWS_DEFAULT_REGION=eu-west-1
aws configure get region
aws ec2 describe-availability-zones --query "AvailabilityZones[].ZoneName" --output textThe first line sets the default for the current shell. The second prints the Region the CLI will use. The third runs a command that picks up that Region without a --region flag. If no Region is configured anywhere, many commands fail with an error that asks you to specify one. Chapter 6 covers the full order in which the CLI looks for this setting.
Placing a resource in a specific AZ
When you create a subnet, you decide which AZ it belongs to. The most reliable way is to use the AZ ID:
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 real one from your account. Using --availability-zone-id rather than --availability-zone removes the ambiguity of per-account name mapping.
Common errors and gotchas
- "My resource vanished." The console is set to a different Region. Check the Region selector in the top bar first.
- Missing Regions in a list. Opt-in Regions do not appear until enabled. Use
--all-regionsto see them. - Assuming AZ letters match across accounts. They may not. Compare AZ IDs, not names.
- Assuming an AZ list means every service is available. Not all services run in every AZ or Region.
- Treating the edge as a place to run your whole app. Edge locations cache and route. Your core workload still lives in a Region.
Summary of the layout
The three layers fit together as a series of choices you make in order:
- Pick a Region based on where your users and legal obligations are.
- Pick AZs within that Region to spread risk.
- Use edge locations and extended zones where lower latency to users justifies them.
The rest of this tutorial expands each step, and then moves on to the Free Tier and the cost controls that keep your exploration from producing a surprise bill.
Exercise
You run aws ec2 describe-availability-zones --region us-east-1 in two different AWS accounts. Both outputs show a zone named us-east-1a, but the zone IDs differ. Is this a mistake, and which identifier should you use when two accounts must place resources in the same physical zone?
Show answer
It is not a mistake. AWS maps zone names to physical zones separately for each account, so the same name can refer to different zones. Use the AZ ID (for example use1-az1), which identifies the same physical zone in every account.
Exercise
You created an EC2 instance, then switched the console to a different Region and the instance is no longer listed. What most likely happened, and how do you confirm it from the CLI?
Show answer
The instance still exists in its original Region. EC2 instances are regional-scoped views, and the console only shows resources for the selected Region. To confirm, run aws ec2 describe-instances --region <original-region> with the Region where you created it.
Exercise
Your boto3 script that lists Availability Zones for a Region returns entries that are not standard AZs. Which filter removes them, and what value do you pass?
Show answer
Filter on zone-type with the value availability-zone, as in Filters=[{"Name": "zone-type", "Values": ["availability-zone"]}]. This leaves out Local Zones and Wavelength Zones.