8

I have hundreds of instances in the EC2 web console.

Some are shutdown. I can see that they were created many months or years ago. They seem abandoned and forgotten for a while but it's hard to tell if terminating them is safe.

e.g. They could be some old backup, someone could have just migrated a load to new instances and keep the old ones for a few weeks as precaution, etc...

We end up keeping most of them as it's the safest choice.

We are still paying for the EBS volumes when the instance is shutdown (but not terminated). The price can escalate over time with many unused instances (EBS is $140 per month per TB). So I'd like to do some cleanup.

I'm thinking that if I could find the time when the instance was shutdown, that would be a good indicator of how "abandoned" it is.

How can I find when an instance was last shutdown?

6

Using the awscli. pip install awscli

aws ec2 describe-instances --output table --instance-id i-aef88019

Output:

|||  StateTransitionReason |  User initiated (2015-11-16 13:36:40 GMT)   |||
[...]
||||                             StateReason                            ||||
|||+---------+----------------------------------------------------------+|||
||||  Code   |  Client.UserInitiatedShutdown                            ||||
||||  Message|  Client.UserInitiatedShutdown: User initiated shutdown   ||||

We can see what happened to the instance and at what time.

For instance, this one was shutdown manually at 2015-11-16 13:36:40 GMT.

  • This does not always include a reason and/or time. Docs say "This might be an empty string". docs.aws.amazon.com/AWSEC2/latest/APIReference/… – Matt Houser Jul 25 '16 at 21:53
  • 1
    It works if the instance was shutdown in the EC2 web console. It doesn't work if the instance was shutdown -h now from inside. It's as much as we can get until Amazon officially adds a "Last Shutdown" meta information to the instances. – user5994461 Jul 26 '16 at 11:34
1

As you mentioned those machines are created many years ago, I think you should check if they are using the old kind of storage call instance store.

In my experience, if you need to shutdown those EC2 machines with instance store, the only option is to terminate it but it would cause data loss.

So my suggestion is to either add a new EBS to backup all data and create a new EC2 with latest settings or simply backup the data remotely. Then terminate the old EC2 instances which should eliminate your storage cost.

0

If your goal is to save money, then you could create an EBS Snapshot of the disks and then delete the volumes.

EBS Snapshots are charged at a lower price than the actual volumes.

For example, in US-East:

  • Snapshots are 9.5c/GB
  • General Purpose SSD EBS volumes are charged at 10c/GB of provisioned storage
  • Older magnetic EBS volumes are charged at 5c/GB of provisioned storage

However, EBS snapshots only require storage space for used blocks. If the EBS volumes have unused space (eg only used 10GB out of 30GB), then EBS snapshots will be cheaper.

If the EBS volumes are mostly full, you could snapshot them and then recreate them as Cold HDD EBS volumes, which are charged at 2.5c/GB of provisioned storage.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.