Sub topic 2
Regions: Isolated Geographic Areas
This chapter assumes you can run commands in a terminal and have an AWS account with the AWS CLI installed and configured with credentials. It also assumes you know what a virtual server and an object store are. The previous chapter gave the overall layout of AWS. This one covers the largest building block, the Region, in detail.
What a Region is
A Region is a separate geographic area where AWS runs infrastructure. Each Region contains multiple Availability Zones (AZs). An AZ is one or more discrete data centers with their own power, cooling, and networking. The next chapter covers AZs. For now, treat a Region as a cluster of AZs in one part of the world, connected by a high-speed private network.
Three properties define a Region:
- Geographic location. A Region sits in a specific area, such as northern Virginia, Ireland, or Sydney. Its AZs are far enough apart to avoid sharing a single failure, but close enough for low-latency links between them.
- Isolation. Regions are independent of each other. Each has its own control plane, which is the set of services that create, change, and delete resources. Each also has its own service endpoints and its own capacity.
- Separate resources. Most resources you create exist in exactly one Region. Nothing is copied to another Region unless you configure it.
Region names and codes
Every Region has a human-readable name and a code. The console shows the name. The CLI, SDKs, templates, and ARNs (Amazon Resource Names, the unique identifiers for resources) use the code.
| Code | Name | Rough location |
|---|---|---|
| us-east-1 | US East (N. Virginia) | Northern Virginia, USA |
| us-west-2 | US West (Oregon) | Oregon, USA |
| eu-west-1 | Europe (Ireland) | Ireland |
| eu-central-1 | Europe (Frankfurt) | Germany |
| ap-southeast-2 | Asia Pacific (Sydney) | Australia |
| sa-east-1 | South America (Sao Paulo) | Brazil |
A code has three parts: a geographic group (us, eu, ap), a direction or area (east, west, central, southeast), and a number that tells apart several Regions in the same area (us-east-1 and us-east-2). The number does not rank Regions or say anything about when they launched.
AWS adds Regions over time, so use the CLI (shown below) to see the current list rather than relying on a table in a tutorial.
What isolation means
Isolation is the main reason Regions exist. It has practical consequences.
Failures stay local. A serious problem in one Region, such as a software defect in a regional service or a large power event, is designed not to spread to other Regions. If you run the same application in two Regions, one outage does not have to take down both.
Data stays where you put it. When you store data in a Region, AWS does not move it to another Region on its own. Replication, backups, or copies to another Region happen only when you set them up, for example with S3 cross-Region replication or by copying an EBS snapshot. This is why compliance teams care about Region choice. The next chapters on Region selection cover this.
Resources do not cross Region lines by default. An EC2 instance in eu-west-1 cannot attach an EBS volume from us-east-1. A security group in one Region cannot be referenced from another. A VPC (Virtual Private Cloud, your private network in AWS) lives in one Region. Connecting two Regions takes explicit steps such as VPC peering, Transit Gateway peering, or VPN.
Capacity, quotas, and prices are per Region. Service quotas apply per Region. Raising your vCPU limit in us-east-1 does nothing for us-west-2. Prices for the same service often differ between Regions. The costs chapter covers that.
Service availability differs. AWS launches new services and features in some Regions first. A service you use in one Region may not exist in another. Check the regional service list before you commit to a Region.
Regional endpoints
Each service in each Region has its own network address, called an endpoint. Most follow this pattern:
https://<service>.<region-code>.amazonaws.comFor example, the EC2 endpoint in Ireland is https://ec2.eu-west-1.amazonaws.com. The CLI and SDKs build this address from the Region you select, so you rarely type it. The pattern still matters for three reasons. It explains why a Region setting changes where requests go. It helps when you read logs or write firewall rules. It shows why a resource "disappears" when you query the wrong Region: you asked a different Region's endpoint, which has no record of it.
A few services are global and use a single endpoint instead, for example AWS Identity and Access Management (IAM). The next chapter on resource scope covers those.
Listing Regions with the CLI
The EC2 API can list Regions. This command prints the codes of the Regions your account can use right now:
aws ec2 describe-regions --query "Regions[].RegionName" --output textThe --query option filters the JSON response with a JMESPath expression. --output text prints the codes separated by tabs. By default the command returns only enabled Regions, so Regions you have not opted in to are left out.
To see every Region, including ones you have not enabled, add --all-regions and filter on OptInStatus:
aws ec2 describe-regions --all-regions \
--query "Regions[?OptInStatus=='not-opted-in'].RegionName" \
--output textThis prints only the Regions that need opt-in and that you have not enabled yet. The command may print nothing if you have enabled them all.
Each entry in the full response has three fields:
RegionName: the code, such aseu-west-1.Endpoint: the EC2 endpoint for that Region.OptInStatus: one ofopt-in-not-required,opted-in, ornot-opted-in.
Default Regions and opt-in Regions
Regions fall into two groups:
- Enabled by default. Most older Regions need no action. Their status is
opt-in-not-required. - Opt-in Regions. Newer Regions are disabled until you enable them for your account. Their status is
not-opted-in, thenopted-inafter you enable them.
Regions launched after March 20, 2019 are opt-in. Examples include af-south-1 (Cape Town) and ap-east-1 (Hong Kong). Opt-in exists so that IAM and other account-level data are not distributed to every new Region before you want to use it. A later chapter covers enabling these Regions step by step. For now, note that a disabled Region will reject your requests until you enable it, and that you can see the current state with the second command above.
Partitions: Regions that never mix
Regions are grouped into partitions. A partition is a set of Regions that share the same account and identity system. Most users work only in the standard aws partition. Two others exist:
aws-cn: the China Regions. These need a separate account and are operated through local providers.aws-us-gov: the AWS GovCloud (US) Regions, for US government workloads and regulated customers. These also need separate accounts.
Credentials from one partition do not work in another. Partition names appear in ARNs, which is why an ARN looks like this:
arn:aws:s3:::example-bucket
arn:aws-cn:s3:::example-bucketThe second field is the partition. Code that builds ARNs by hand with a fixed arn:aws: prefix will break in aws-cn and aws-us-gov. Prefer to read the partition from the SDK or from an existing ARN.
Common errors
These problems come from Region mistakes.
"My resource is gone." You created it in one Region and are viewing another. In the console, check the Region selector at the top right. In the CLI, run aws configure get region and compare it with the Region where you created the resource. Pass --region to override.
A command works in one Region and fails in another. The service or feature may not be offered in the second Region. Check the regional service list in the AWS documentation before assuming a permissions problem.
Authentication errors in a newly launched Region. If the Region is an opt-in Region, you may not have enabled it. Check OptInStatus. Enabling can take a short while to take effect.
Hard-coded Region codes. A template or script with us-east-1 written in many places is hard to move. Pass the Region as a parameter, and read it from configuration.
Duplicate resources in forgotten Regions. Experiments left running in a Region you stopped looking at still cost money. The final chapters on cost controls cover how to find them.
Summary
A Region is an isolated geographic area with its own AZs, endpoints, quotas, prices, and service list. Resources live in one Region unless you copy or replicate them. The Region code selects the endpoint that receives your requests. Some Regions are enabled by default and others need opt-in. Partitions keep the China and GovCloud Regions separate from the rest. Most "missing resource" problems turn out to be requests sent to the wrong Region.
Exercise
You created an S3-backed application and an EC2 instance in eu-west-1. A teammate runs aws ec2 describe-instances from their laptop and sees no instances. Their aws configure get region prints us-east-1. Name the cause, and give two ways to fix the command.
Show answer
The teammate's CLI sends the request to the us-east-1 endpoint, which has no record of an instance in eu-west-1. Fix it by passing --region eu-west-1 on the command, or by changing the default Region for the shell, for example with export AWS_DEFAULT_REGION=eu-west-1 or aws configure set region eu-west-1.
Exercise
Write a command that lists only the Regions your account has not yet enabled. Then explain why a plain aws ec2 describe-regions would not show them.
Show answer
aws ec2 describe-regions --all-regions --query "Regions[?OptInStatus=='not-opted-in'].RegionName" --output text. Without --all-regions, the call returns only enabled Regions, which are those with status opt-in-not-required or opted-in.
Exercise
A script builds the ARN arn:aws:s3:::my-bucket by string concatenation. Why can this fail for some customers even though the Region code is correct?
Show answer
The aws prefix is the partition for the standard Regions. In the China and GovCloud partitions the prefix is aws-cn or aws-us-gov, so the hard-coded ARN names a resource that does not exist there. Read the partition from the SDK or from an existing ARN instead.