If I shut down Amazon EC2 instance then start it again, will everything be ok?

Solution 1:

Stopping and starting an EBS boot instance is very similar to simply rebooting the instance with a few exceptions, the most notable being:

  1. The instance is assigned a new internal IP address.

  2. The instance is assigned a new public IP address.

  3. If the instance is not in a VPC, then any Elastic IP address is disassociated with the instance.

  4. All data on ephemeral storage (often under /mnt) is lost

There are also some billing and availability implications which I described in this article:

Rebooting vs. Stop/Start of Amazon EC2 Instance
http://alestic.com/2011/09/ec2-reboot-stop-start

VPC instances have slightly different behavior including keeping Elastic IP addresses through stop/start.

If you are using an instance as a database server and you want to connect to it using the internal IP address (cheaper, faster) and you don't want to have to reconfigure the database clients after a stop/start, then you can assign an Elastic IP address to the instance and use the external Elastic IP DNS name. This will resolve to the current internal IP address after you re-associate the Elastic IP address to the restarted instance and your clients will pick up where they left off.

I go into more detail about this approach in this article:

Using Elastic IP to Identify Internal Instances on Amazon EC2
http://alestic.com/2009/06/ec2-elastic-ip-internal

As it sounds like you've anticipated, stop/start is an easy way to change the hardware powering your instance. I wrote about this along with some instructions and warnings in this article:

Moving an EC2 Instance to a Larger (or Smaller) Instance Type
http://alestic.com/2011/02/ec2-change-type

For your particular situation I would recommend assigning an Elastic IP address to the instance and changing your DNS to point to the Elastic IP address using a CNAME to the external DNS name. You could do this right after the stop/start, or you could do it ahead of time making sure everything works before the stop/start.

Solution 2:

So, looks like you are not using Elastic IP, as I can see from your information.

I believe you must be using CNAME in the DNS to point to this instance. If you restart you Machine then this ec2-54-1-1-1.us-west-1.compute.amazonaws.com DNS name will change and your site will stop working.

As much internal IP is concerned, it will also change, unless you are using VPC, which you are not.

So, If I were you, I will be very careful in restarting this Machine.

As much as Time is concerned, it won't take anything more than couple of minutes.

Also, if you have any iptables running at the DB instance, which is allowing just this internal IP to connect to the DB, then it also won't work, as your internal IP will change.

So, Please be careful if you want to restart this instance, and think throughly about it.