The four buttons that look alike
The EC2 console offers Reboot, Stop, Hibernate and Terminate next to each other. They read like gentler and harsher versions of the same thing. They are not. Stop and start an instance that a DNS record points at, and the record now points at an address that is no longer yours.
Think of the instance as a desk you rent. Rebooting is closing your laptop and opening it again at the same desk. Stopping is going home for the night: your locker (the EBS volume) is still yours, but tomorrow you may sit at a different desk with a different phone number. Terminating is handing back the keys.
1. Stop pressed. EC2 shuts the operating system down cleanly, or forces it after a few minutes if it will not stop.
The full comparison
This is the table in the EC2 User Guide, in fewer words:
| Reboot | Stop, then start | Hibernate | Terminate | |
|---|---|---|---|---|
| Host | Same | Usually new | Usually new | None |
| Private IPv4 | Kept | Kept | Kept | None |
| Public IPv4 | Kept | New | New | None |
| Elastic IP | Stays | Stays | Stays | Disassociated |
| Instance store data | Kept | Erased | Erased | Erased |
| Root EBS volume | Kept | Kept | Kept | Deleted by default |
| Memory | Erased | Erased | Saved to the root volume | Erased |
Stop and hibernate only work for instances whose root volume is EBS. Be careful with a shutdown from inside the operating system. On an EBS-backed instance it stops the instance by default. On an instance whose root volume is instance store, it always terminates it.
See it for yourself
Run this before and after a stop and start:
aws ec2 describe-instances --instance-ids i-1234567890abcdef0 \
--query 'Reservations[].Instances[].[State.Name,PublicIpAddress,PrivateIpAddress]' \
--output table
The private address will match. The public one will not.
What to do about it
- Need a stable address? Associate an Elastic IP. AWS charges for every public IPv4 address, in use or not, so release it when you are done.
- Better still, put a load balancer in front and point DNS at that. Then no single instance's address matters.
- Keep data you care about on EBS or S3, never on instance store disks.
- Check the delete-on-termination setting of any volume you expect to outlive the instance.
Where to go next
The Amazon EC2 guide covers instance types, connecting without opening port 22, IMDSv2 (the safer version of the instance metadata service) and fixes for the usual SSH errors. The network around the instance, and why a subnet is public, is in the VPC guide.
Enjoyed this article?
Get more DevOps insights delivered to your inbox.
Get new posts by email
Subscribe to get an email when a new blog post is published. Skip anytime.
No spam, unsubscribe anytime.
Related Posts
Discussion
0 comments
Sign in to join the conversation.
Be the first to comment
Start a conversation about this post



