How to use boto3 to get a list of my EBS snapshots?

I used boto3 in the past to find all images that were not public , to reduce the list of returned images from thousands to a managed number.

However, I cannot decide how to filter the EBS snapshots this way. I tried the following

 ec2.describe_snapshots(OwnerIds=self) 

However, OwnerIds only accepts a list of identifiers.

I read the following documentation: describe_snapshots and it claims to be

Results may include AWS account identifiers of the specified owners, amazon for Amazon-owned snapshots, or self for your own snapshots

but I cannot decide where this self should go. Can anyone help? Thanks.

+5
source share
1 answer

Try:

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

or you can specify your account number / identifier:

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

Both are equivalent.

+6
source

Source: https://habr.com/ru/post/1268884/


All Articles