Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use boto3 to get a list of EBS snapshots owned by me?

I have used boto3 in the past to find all images which were not public, so as to decrease my list of returned images from the thousands to a manageable number.

However, I can not work out how to filter EBS snapshots in this fashion. I have tried the following

ec2.describe_snapshots(OwnerIds=self)

However, OwnerIds only takes a list of Ids.

I have been reading the following documentation: describe_snapshots, and it states that

The results can include the AWS account IDs of the specified owners, amazon for snapshots owned by Amazon, or self for snapshots that you own

but I can not work out where this self is meant to go. Can anybody help? Thanks.

like image 866
x3nr0s Avatar asked Jun 15 '17 17:06

x3nr0s


1 Answers

Try:

client.describe_snapshots(OwnerIds=['self'])

or you can specify your account number/id:

client.describe_snapshots(OwnerIds=['123456736123'])

Both are equivalent.

like image 157
helloV Avatar answered Oct 16 '22 09:10

helloV