Is it possible to retain IP address when stopping/starting an AWS EC2 instance

amazon ec2amazon-web-services

Reading Amazon's documentation it appears that the default behavior for an EC2 instance to to release the current IP address and reassign a new one at some point in the processes depending on whether you are using Classic or VPC:

EC2-Classic: We release the public and private IPv4 addresses for the
instance when you stop the instance, and assign new ones when you
restart it.

EC2-VPC: The instance retains its private IPv4 addresses and any IPv6
addresses when stopped and restarted. We release the public IPv4
address and assign a new one when you restart it.

In my environment it would be nice if I could find a way to retain the IP address. Does anyone know of a way to do this with EC2 instances?

Best Answer

Assign an Elastic IP to your instance. That IP is yours until you release it. Stop, start, terminate, reassign to a different instance, you can do whatever you like.

Elastic IPs are free, but cost a small amount if they're not attached to a running instance.

There's no way to retain the automatically assigned public IP through a stop / start cycle.

Related Topic