Dan
Dan

Reputation: 183

How do you tell if an AWS Snapshot has been deleted?

I am trying to delete orphaned snapshots, but the query I am using keeps giving me snapshots that are deleted. Is there a query I can use to avoid deleted snapshots?

aws ec2 describe-snapshots --snapshot-id snap-00012345cac2b3de1
{
    "Snapshots": [
        {
            "Description": "DescriptionHere",
            "Encrypted": false,
            "OwnerId": "123456088429",
            "Progress": "100%",
            "SnapshotId": "snap-00012345cac2b3de1",
            "StartTime": "2018-01-24T06:42:50+00:00",
            "State": "completed",
            "VolumeId": "vol-00123dc456ad5117",
            "VolumeSize": 6,
            "StorageTier": "standard"
        }
    ]
}

Upvotes: 0

Views: 537

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269666

To test your situation, I did the following:

  • Went to the EC2 Management Console and displayed Amazon EBS Volumes
  • Created a Snapshot of an EBS Volume: snap-036851d7351b78712
  • Ran aws ec2 describe-snapshots --snapshot-id snap-036851d7351b78712
  • It returned a result similar yours
  • Deleted the Snapshot in the Management Console
  • Ran the above command again. The result was:

An error occurred (InvalidSnapshot.NotFound) when calling the DescribeSnapshots operation: The snapshot 'snap-036851d7351b78712' does not exist.

So, I was unable to reproduce your situation.

I then wondered whether the Snapshot might be associated with an AMI. I did the following:

  • Created an AMI of an existing Amazon EC2 instance
  • Waited until the AMI creation was complete
  • Listed Snapshots in the console -- a new snapshot appeared snap-047563373ab4c1088
  • I then tried to delete the snapshot, but received the message:

snap-047563373ab4c1088: The snapshot snap-047563373ab4c1088 is currently in use by ami-0fc62425d087dbbe8

I then 'deregistered' (deleted) the AMI and it told me that the associated Snapshot would not be deleted:

Deregister EC2 AMI

  • I then manually deleted the Snapshot in the console
  • I used describe-snapshots and it said that the snapshot did not exist

So, perhaps your Snapshot is associated with an AMI and it was never actually deleted?

Upvotes: 1

Related Questions