Sub topic 2
Regions: isolated geographic areas
This chapter assumes you have an AWS account, can run commands in a terminal, and know what a virtual server and an IP address are. It covers what a Region is, how Regions are named, which ones your account can use, and the mistakes that most often confuse people.
What a Region is
A Region is a separate geographic area where AWS runs data centers. Each Region has a code such as us-east-1 (N. Virginia) or eu-west-1 (Ireland). Each one is independent of the others. It has its own power, its own network, its own service endpoints, and its own copy of most services.
Independence is the main design goal. A failure in one Region should not spread to another. It also means that resources you create in one Region do not appear in another unless you copy or replicate them yourself.
Every Region contains multiple Availability Zones (AZs). The next chapter covers those. For now, treat a Region as the container that holds them.
How Regions are named
A Region has two identifiers:
- The Region code, such as
eu-central-1. You use this in the CLI, SDKs, and templates. - The Region name, such as Europe (Frankfurt). You see this in the console.
The code follows the pattern geography, direction, number. For example, ap-southeast-2 is Asia Pacific, southeast, second Region in that area.
Regions and service endpoints
Each service has a separate endpoint in each Region. An endpoint is the URL your client calls. For Amazon EC2 in Ireland, it is ec2.eu-west-1.amazonaws.com. When you pick a Region, you are picking which endpoint your request goes to. This is why the same command can return different results depending on the Region.
Listing Regions with the CLI
This command lists the Regions that are enabled for your account:
aws ec2 describe-regions --query "Regions[].RegionName" --output textThe list leaves out opt-in Regions that you have not enabled. To see those, include all Regions and filter on the opt-in status:
aws ec2 describe-regions --all-regions \
--query "Regions[?OptInStatus=='not-opted-in'].RegionName" \
--output textEach Region reports one of three values for OptInStatus:
| OptInStatus | Meaning |
|---|---|
| `opt-in-not-required` | Enabled by default for every account |
| `opted-in` | An opt-in Region that you have enabled |
| `not-opted-in` | An opt-in Region that you have not enabled |
Opt-in Regions
Most Regions are available as soon as you create an account. Some newer ones are opt-in Regions, which are disabled until you enable them. You enable one from the account settings in the console, and it takes a few minutes. Until then, calls to that Region fail.
Enabling a Region has one side effect worth knowing. IAM identities such as users and roles are global, so they work in the new Region without being recreated. Data and resources you create there stay in that Region.
Common errors
These are the problems intermediate users hit most often.
- "My resources disappeared." You are looking at a different Region. Check the Region selector in the console, or the Region your CLI is using.
- "Could not connect to the endpoint URL." The Region code is mistyped, or the service is not offered in that Region.
- "The security token is invalid" for a new Region. The Region is an opt-in Region that has not finished enabling.
- Unexpected charges. A forgotten resource is running in a Region you do not normally open. Prices also differ by Region.
Why isolation matters
Isolation affects three decisions:
- Resilience. An event that affects one Region leaves the others working.
- Data location. Your data stays in the Region you chose unless you configure a copy or transfer. Many compliance rules depend on this.
- Latency. Distance still counts, so a Region far from your users adds delay.
Later chapters cover how to weigh these when choosing a Region.
Exercise
You run aws ec2 describe-regions --query "Regions[].RegionName" --output text and a newly launched opt-in Region is not in the output. What is the likely reason, and which command would show it?
Show answer
The Region is an opt-in Region that your account has not enabled, so the default call leaves it out. Run aws ec2 describe-regions --all-regions --query "Regions[?OptInStatus=='not-opted-in'].RegionName" --output text to list the Regions that are not yet enabled.