如何使用boto3获取我拥有的EBS快照列表? [英] How to use boto3 to get a list of EBS snapshots owned by me?

查看:113
本文介绍了如何使用boto3获取我拥有的EBS快照列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我过去曾使用boto3查找所有不公开的图像,以便将返回的图像列表从数千个减少到一个可管理的数目。 / p>

但是,我不知道如何以这种方式过滤EBS快照。
我尝试了以下操作

  ec2.describe_snapshots(OwnerIds = self)

但是,OwnerIds仅带有ID列表。



我一直在阅读以下文档: describe_snapshots ,指出


结果可以包括指定所有者的AWS账户ID,Amazon拥有的快照的
Amazon或self对于您
拥有的快照


,但我无法计算出自身的位置是要走的。
有人可以帮忙吗?谢谢。

解决方案

尝试:

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

或者您可以指定帐户数字/ ID:

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

两者都是等效的。


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.

解决方案

Try:

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

or you can specify your account number/id:

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

Both are equivalent.

这篇关于如何使用boto3获取我拥有的EBS快照列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆