Lajpat
Lajpat

Reputation: 633

Connecting EC2 within VPC in AWS

If I have to make a call to another EC2 in my VPC then I will need either its IP address or private DNS name

But if second EC2 needs to be replaced then I will have to update first EC2 as well

So what is the best way to do so.

Also what is a good use case for this scenario

Upvotes: 0

Views: 44

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269101

A good practice is to use DNS names to refer to other instances rather than their IP address. This way, the instances can be substituted without having to update the reference.

  • Creating a Private Hosted Zone in Amazon Route 53 for your subnet
  • When creating an instance, call Amazon Route 53 to add or update a Record Set that points to the instance (eg server1.internal)

The instance that starts could even call Route 53 and register itself. For example, when it starts if it knows what it is (eg an accounting system), it can register itself as accounting.internal. If that instance fails and another starts up with the same startup code, the new instance would update the DNS entry to point to itself.

Upvotes: 1

Related Questions