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

走远了吗. 提交于 2020-05-08 06:45:11

问题


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.


回答1:


Try:

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

or you can specify your account number/id:

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

Both are equivalent.



来源:https://stackoverflow.com/questions/44573768/how-to-use-boto3-to-get-a-list-of-ebs-snapshots-owned-by-me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!