Matching EC2 Availability Zones Across AWS Accounts

| 1 Comment | 0 TrackBacks

Summary: EC2 availability zone names in different accounts do not match to the same underlying physical infrastructure. This article explains a trick which can be used to figure out how to match availability zone names between different accounts.

Background

As of the writing of this article, Amazon EC2 (Elastic Compute Cloud) has six different availability zones in two regions. A region can be thought of as a specific area of the world. An availability zone can be thought of roughly as a data center, defined such that no single failure scenario should affect two availability zones.

The current regions are:

  • us-east-1 - East coast of the United States (probably near Washington, DC)
  • eu-west-1 - Western Europe (probably near Dublin, Ireland)

The availability zones in those regions are given the region name plus simple letters appended:

  • us-east-1a
  • us-east-1b
  • us-east-1c
  • us-east-1d

and

  • eu-west-1a
  • eu-west-1b

When you start EC2 instances, you can specify an availability zone or let Amazon pick one for you. You always have a default region which can be overridden when starting instances.

Balancing

In order to prevent an overloading of a single availability zone when everybody tries to run their instances in us-east-1a, Amazon has added a layer of indirection so that each account’s availability zones can map to different physical data center equivalents.

For example, zone us-east-1a in your account might be the same as zone us-east-1c in my account and us-east-1d in a third person’s account.

In fact, given the way that Amazon has set this up, I would not be surprised if Amazon may not occasionally reassign availability zone names which you are not currently using. For example, Amazon recently added the fourth availability zone in the us-east-1 region, but I suspect this might not be us-east-1d in all accounts (especially new ones).

Identification

On occasion, users sometimes want to know if instances in different accounts are running in the same availability zone. Or, users might want to know which availability zone is the one with which people are currently experiencing a particular problem.

You’ll often see users say that there is a problem in zone us-east-1a but this isn’t very helpful for other users because (as described above) that name only has significance within the original user’s account.

What would be helpful is a unique identifier which maps to the underlying physical infrastructure (e.g., data center) and can be mapped to the different availability zone names in each account.

I believe that Amazon may have inadvertently let slip a way to obtain this in the current implementation of the reserved instance offering ids. In my experiments so far, these seem to be tied to something outside of the account’s availability zones and, though the ids are the same, they are mapped to different availability zone names for different accounts.

To demonstrate this I’ve arbitrarily chosen the reserved instance offerings for m1.small, one year, Linux.

To list the mappings for a single account, you can use a command like:

ec2-describe-regions | cut -f2 | while read region; do 
  ec2-describe-reserved-instances-offerings --region $region | 
    perl -ne 'print "$2 $1\n" if 
      m%\S+\t(\S+)\t(\S+)\tm1.small\t1y.\t.*\tLinux%'; 
done | sort

Examples

Here are the mappings for one of my accounts (let’s call it “Blue”):

eu-west-1a 649fd0c8-75d4-4e16-88c7-1ddb83f66062
eu-west-1b 438012d3-0440-480a-9f5c-eb7e55dd5a37
us-east-1a 4b2293b4-1e6c-4eb3-ab74-4493c0e57987
us-east-1b 60dcfab3-a56c-4092-8c90-3677e9da02b7
us-east-1c c48ab04c-c057-457e-a4d8-a0f172f4db2d
us-east-1d c48ab04c-7e96-4ea8-9579-d62194490546

Here are the mappings for a different account (let’s call it “Red”):

eu-west-1a 438012d3-0440-480a-9f5c-eb7e55dd5a37
eu-west-1b 649fd0c8-75d4-4e16-88c7-1ddb83f66062
us-east-1a c48ab04c-c057-457e-a4d8-a0f172f4db2d
us-east-1b 4b2293b4-1e6c-4eb3-ab74-4493c0e57987
us-east-1c 60dcfab3-a56c-4092-8c90-3677e9da02b7
us-east-1d c48ab04c-7e96-4ea8-9579-d62194490546

From this, I theorize that availability zone us-east-1a in account Blue is the same as availability zone us-east-1b in account Red, but availability zones us-east-1d happen to be the same in both accounts.

Caveats

Please note that this approach is not a documented feature of Amazon EC2. I may be misinterpreting what I am seeing and the mappings may be completely random for different accounts.

Amazon could at any time restructure how these values work so that the described offering ids cannot be used between accounts or do not map to any common infrastructure.

Use at your own risk and please post a comment if you find out any further data to support or disprove this theory.

No TrackBacks

TrackBack URL: http://alestic.com/mt/mt-tb.cgi/39

1 Comment

Awesome - thanks!

This can help eliminate cross-availability-zone networking charges when I copy data from my Testing account to/from my Production account. In order to restrict access to the Production deployment I have two separate AWS accounts, Testing and Production. The AZs in these accounts do not match, and I sometimes end up being charged for transferring data between (instances belonging to) the two accounts. Using your tip I can figure out where to deploy my Testing instances to save $$ transferring data between instances belonging to the different accounts.

Leave a comment

Stay Updated

Subscribe with email address:
 Subscribe with a reader
Join the EC2 Ubuntu Google Group
Follow Eric Hammond on Twitter

More Entries

Understanding Access Credentials for AWS/EC2
Amazon Web Services (AWS) has a dizzying proliferation of credentials, keys, ids, usernames, certificates, passwords, and codes which are used…
How *Not* to Upgrade to Ubuntu 9.10 Karmic on Amazon EC2
WARNING! Though most Ubuntu 9.04 Jaunty systems can upgrade to 9.10 Karmic in place, this is not possible on EC2…
1 TB of Memory in 1 Minute with 1 Command
Amazon Web Services just announced the release of two new instance types for EC2. These new types have 34.2 GB…
New Releases of Ubuntu and Debian Images for Amazon EC2 (Kernel, Security, PPA, runurl, Tools)
New updates have been released for the Ubuntu and Debian AMIs (EC2 images) published on: http://alestic.com The following notes apply…
Encrypting Ephemeral Storage and EBS Volumes on Amazon EC2
Over the years, Amazon has repeatedly recommended that customers who care about the security of their data should consider encrypting…
Creating Consistent EBS Snapshots with MySQL and XFS on EC2
In the article Running MySQL on Amazon EC2 with Elastic Block Store I describe the principles involved in using EBS…
Hidden Dangers in Creating Public EBS Snapshots on EC2
Amazon EC2 recently released a feature which lets you share an EBS snapshot so that other accounts can access it.…
Solving: "I can't connect to my server on Amazon EC2"
Help! I can’t connect to my EC2 instance! Woah! My box just stopped talking to me! Hey! I can’t access…
runurl - A Tool and Approach for Simplifying user-data Scripts on EC2
Many Ubuntu and Debian images for Amazon EC2 include a hook where scripts passed as user-data will be run as…
Presentation: Building Custom Linux Images for Amazon EC2
At the end of July, I gave a presentation at O’Reilly’s Open Source Convention (OSCON 2009) in San Jose. The…
New Releases of Ubuntu and Debian Images for Amazon EC2 (Tools, Security)
New updates have been released for the Ubuntu and Debian AMIs (EC2 images) published on: http://alestic.com The following notes apply…
Poll: Verifying ssh Fingerprint on EC2 Instances
When you ssh to a new EC2 instance, you are presented with the challenge: The authenticity of host 'XXX' can't…
EBS Snapshots of a MySQL Slave Database on EC2
At our company, CampusExplorer.com, we regularly snapshot the EBS volume which holds our MySQL database using the basic procedure I…
Matching EC2 Availability Zones Across AWS Accounts
Summary: EC2 availability zone names in different accounts do not match to the same underlying physical infrastructure. This article explains…
Does Your Product Help Users Build AMIs for Amazon EC2?
I will be speaking at the O’Reilly Open Source Convention (OSCON 2009) next week, giving a presentation on building custom…
Creating a New Image for EC2 by Rebundling a Running Instance
When you start up an instance (server) on Amazon EC2, you need to pick the image or AMI (Amazon Machine…
New Releases of Ubuntu Images for Amazon EC2 2009-06-23 (Karmic Koala Alpha released)
Ubuntu Karmic Koala Alpha is being developed and will be released as Ubuntu 9.10 in October. If you want to…
Using RAID on EC2 EBS Volumes to Break the 1TB Barrier and Increase Performance
Amazon EC2 currently has a limit of 1,000 GB (1 TB) for EBS volumes (Elastic Block Store). It is possible…
New Releases of Ubuntu and Debian Images for Amazon EC2 2009-06-14 (Reliability and Security)
New updates have been released for the Ubuntu and Debian AMIs (EC2 images) published on: http://alestic.com The following improvements are…
Repost: Hiring EC2/AWS Developers/Engineers
Reposting a response I wrote to a user on Amazon’s EC2 forum who is having a hard time finding good…