How to find out when an EC2 instance was shutdown?

Solution 1:

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.

Solution 2:

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.