Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm currently using Heroku (which uses AWS) and my program needs to communicate with my own EC2 instance. I've made my EC2 instance in the same Region as Herokus', however, in order to reduce costs further I want to be able to community via the private IP address between my Heroku dyno and EC2 instance in the same Availability Zone.

I know I can restart Heroku to switch between servers and potentially different availability zones, however, is there any way to determine if they're in the same availability zone or in a different availability zone?

Potentially I can write a program that will restart Heroku to the point that it is in the same zone.

share|improve this question
up vote 3 down vote accepted

That's not an easy task (if solvable at all), because availability zones are different per Amazon EC2 account in the first place, see FAQ How can I make sure that I am in the same Availability Zone as another developer?:

We do not currently support the ability to coordinate launches into the same Availability Zone across AWS developer accounts.

Eric Hammond has explored the topic and developed a technique/trick to work around this limitation, see 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 a trick which can be used to figure out how to match availability zone names between different accounts.

However, he stresses the respective caveats as well:

Please note that this approach is not a documented feature of Amazon EC2. [...]

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.

The trick seems to work for the time being, so you might be able to achieve your goal by applying this technique, but be prepared for it not yielding a reliable solution down the road eventually.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.