问题
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