0

in the application I manage, in several places, there are hard-coded references to the Private DNS of an EC2. The code will refer to: ip-(some private IP here).eu-west-1.compute.internal.

If I stop and start an instance the private IP will change, and I assume also that the Private DNS URL will also change.

When this happens the code crashes. Is there any way I can avoid this change? Is there some way to create a Private DNS so it does not change even when an instance is stopped and started again?

Nora
  • 1,825
  • 8
  • 31
  • 47
  • are you sure about change of the address in the event of stop and start? From the docs: https://docs.aws.amazon.com/vpc/latest/userguide/vpc-ip-addressing.html A private IP address remains associated with the network interface when the instance is stopped and restarted, and is released when the instance is terminated. – Anton Apr 17 '20 at 12:17

1 Answers1

1

The private DNS and the IP shouldn't change.

However one feasible option is to launch your instances within a VPC and assign a Route 53 Private Hosted Zone that resolves your instances.

The bridge between VPC and Route53 is a DHCP options in the VPC.

Leonardo
  • 9,607
  • 17
  • 49
  • 89