我想使用 boto3 获取 EC2 快照权限的值。
describe_snapshots() 函数不包含快照权限值,如何获取它?
owner_ids = []
instances = get_describe_instances()
for instance in instances:
print(instance['OwnerId'])
owner_ids.append(instance['OwnerId'])
snapshots = get_describe_snapshots(list(owner_ids))
for snapshot in snapshots:
print(snapshot)
谢谢你。
我尝试使用以下功能但无法得到任何结果。 描述快照属性 描述快照层状态 EBS资源
我有相同的请求,但无论如何都看不到过滤私有快照,我通过在所有快照和公共快照之间使用不同的设置来解决方法,如下所示:
all_ebs_list = []
public_ebs_list = []
all_ebs_response = boto3.client('ec2').describe_snapshots(OwnerIds=['self'], RestorableByUserIds=['self'])
[all_ebs_list.append(_['SnapshotId']) for _ in response['Snapshots']]
public_ebs_response = boto3.client('ec2').describe_snapshots(OwnerIds=['self'], RestorableByUserIds=['all'])
[public_ebs_list.append(_['SnapshotId']) for _ in response['Snapshots']]
private_ebs_list = list(set(all_ebs_list) - set(public_ebs_list))
private_ebs_response = boto3.client('ec2').describe_snapshots(SnapshotIds=private_ebs_list)