I am getting the following Error while deleting snapshots. I wanted to delete Snapshot which are currently not in use by My AWS AMI's and Other Instances.. as well .I tried but got this error..
Traceback (most recent call last):
<path to error file>
EC2ResponseError: EC2ResponseError: 400 Bad Request
<?xml version="1.0" encoding="UTF-8"?><Response><Errors><Error><Code>InvalidSnapshot.InUse</Code><Message>The snapshot snap-xxxxxxxx is currently in use by ami-xxxxxxxx</Message></Error></Errors><RequestID>bbe55333-4acf-4ca7-9aa3-49307b189ca3</RequestID></Response>
Unfortunately, there is not an API to get AMI ID directly from an EBS snapshot.
Instead, you can go the other way.
ec2:DescribeImages
to get a list of AMI images. Edit: Another possibility:
You may be able to use ec2:DescribeImages
with a filter on the EBS snapshot ID.
https://ec2.amazonaws.com/?Action=DescribeImages
&Filter.1.Name=block-device-mapping.snapshot-id
&Filter.1.Value=snap-xxxx
Reference: http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeImages.html