The hidden truth behind AWS Availability Zones

Picture this, you’ve designed a top-notch, highly available architecture on AWS. Your resources are meticulously distributed across multiple Availability Zones (AZs) within a region, ensuring fault tolerance. Yet, an unexpected connectivity issue emerges between accounts. What could be the cause? The answer lies in an often-overlooked aspect of how AWS manages Availability Zones.

Understanding AWS Availability Zones

AWS Availability Zones are isolated locations within an AWS Region, designed to enhance fault tolerance and high availability. Each region comprises multiple AZs, each engineered to be independent of the others, with high-speed, redundant networking connecting them. This design makes it possible to create applications that are both resilient and scalable.

On the surface, AZs seem straightforward. AWS Regions are standardized globally, such as us-east-1 or EU-west-2. However, the story becomes more intriguing when we dig deeper into how AZ names like us-east-1a or eu-west-2b are assigned.

The quirk of AZ names

Here’s the kicker: the name of an AZ in your AWS account doesn’t necessarily correspond to the same physical location as an AZ with the same name in another account. For example, us-east-1a in one account could map to a different physical data center than us-east-1a in another account. This inconsistency can create significant challenges, especially in shared environments.

Why does AWS do this? The answer lies in resource distribution. If every AWS customer within a region were assigned the same AZ names, it could result in overloading specific data centers. By randomizing AZ names across accounts, AWS ensures an even distribution of resources, maintaining performance and reliability across its infrastructure.

Unlocking the power of AZ IDs

To address the confusion caused by randomized AZ names, AWS provides AZ IDs. Unlike AZ names, AZ IDs are consistent across all accounts and always reference the same physical location. For instance, the AZ ID use1-az1 will always point to the same physical data center, whether it’s named us-east-1a in one account or us-east-1b in another.

This consistency makes AZ IDs a powerful tool for managing cross-account architectures. By referencing AZ IDs instead of names, you can ensure that resources like subnets, Elastic File System (EFS) mounts, or VPC peering connections are correctly aligned across accounts, avoiding misconfigurations and connectivity issues.

Common AZ IDs across regions

  • US East (N. Virginia): use1-az1 | use1-az2 | use1-az3 | use1-az4 | use1-az5 | use1-az6
  • US East (Ohio): use2-az1 | use2-az2 | use2-az3
  • US West (N. California): usw1-az1 | usw1-az2 | usw1-az3
  • US West (Oregon): usw2-az1 | usw2-az2 | usw2-az3 | usw2-az4
  • Africa (Cape Town): afs1-az1 | afs1-az2 | afs1-az3

Why AZ IDs are essential for Multi-Account architectures

In multi-account setups, the randomization of AZ names can lead to headaches. Imagine you’re sharing a subnet between two accounts. If you rely solely on AZ names, you might inadvertently assign resources to different physical zones, causing connectivity problems. By using AZ IDs, you ensure that resources in both accounts are placed in the same physical location.

For example, if use1-az1 corresponds to a subnet in us-east-1a in your account and us-east-1b in another, referencing the AZ ID guarantees consistency. This approach is particularly useful for workloads involving shared resources or inter-account VPC configurations.

Discovering AZ IDs with AWS CLI

AWS makes it simple to find AZ IDs using the AWS CLI. Run the following command to list the AZs and their corresponding AZ IDs in a region:

aws ec2 describe-availability-zones --region <your-region>

The output will include the ZoneName (e.g., us-east-1a) and its corresponding ZoneId (e.g., use1-az1). Here is an example of the output when running this command in the eu-west-1 region:

{
    "AvailabilityZones": [
        {
            "State": "available",
            "OptInStatus": "opt-in-not-required",
            "Messages": [],
            "RegionName": "eu-west-1",
            "ZoneName": "eu-west-1a",
            "ZoneId": "euw1-az3",
            "GroupName": "eu-west-1",
            "NetworkBorderGroup": "eu-west-1",
            "ZoneType": "availability-zone"
        },
        {
            "State": "available",
            "OptInStatus": "opt-in-not-required",
            "Messages": [],
            "RegionName": "eu-west-1",
            "ZoneName": "eu-west-1b",
            "ZoneId": "euw1-az1",
            "GroupName": "eu-west-1",
            "NetworkBorderGroup": "eu-west-1",
            "ZoneType": "availability-zone"
        },
        {
            "State": "available",
            "OptInStatus": "opt-in-not-required",
            "Messages": [],
            "RegionName": "eu-west-1",
            "ZoneName": "eu-west-1c",
            "ZoneId": "euw1-az2",
            "GroupName": "eu-west-1",
            "NetworkBorderGroup": "eu-west-1",
            "ZoneType": "availability-zone"
        }
    ]
}

By incorporating this information into your resource planning, you can build more reliable and predictable architectures.

Practical example for sharing subnets across accounts

Let’s say you’re managing a shared subnet for two AWS accounts in the us-east-1 region. Using AZ IDs ensures both accounts assign resources to the same physical AZ. Here’s how:

  1. Run the CLI command above in both accounts to determine the AZ IDs.
  2. Align the resources in both accounts by referencing the common AZ ID (e.g., use1-az1).
  3. Configure your networking rules to ensure seamless connectivity between accounts.

By doing this, you eliminate the risks of misaligned AZ assignments and enhance the reliability of your setup.

Final thoughts

AWS Availability Zones are the backbone of AWS’s fault-tolerant architecture, but understanding their quirks is crucial for building effective multi-account systems. AZ names might seem simple, but they’re only half the story. Leveraging AZ IDs unlocks the full potential of AWS’s high availability and fault-tolerance capabilities.

The next time you design a multi-account architecture, remember to think beyond AZ names. Dive into AZ IDs and take control of your infrastructure like never before. As with many things in AWS, the real power lies beneath the surface.

Share