How to address an EC2 instance from both inside and outside datacenter?

Alexandr Kurilin asked:

I’m trying to find a good way of being able to address my EC2 database instance from both inside and outside of the datacenter. Other EC2 instances need to be able to call into it, and other clients like pgAdmin might need to connect to it from the outside world as well.

It’s my understanding that using the internal and external DNS names is sustainable long term as each reboot leads to a change.

I’m thinking of associating an Elastic IP with the instance and giving it an A record (say which I then will use both within and outside the datacenter. Further instances in the same role will get the same treatment and a DNS record of etc.

Now, is there a cleaner and more stable way of achieving this result? Am going about this the wrong way? Suggestions?

My answer:

Associating an Elastic IP with the instance is how this is done.

Be aware, that unless you are using VPC, that your elastic IP will disassociate if you stop the instance, and you will have to manually reassociate it when you restart the instance.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.