我正在尝试删除任何包含tags_description
描述的先前快照,我该怎么办?以下代码会引发错误:
def call_cleaner(data): regions = ['us-west-2','eu-central-1','ap-southeast-1']
for index, region in enumerate(regions):
for ip_address, tags_descrip, regions_az, volume_id in data[index]:
ec2 = boto3.resource('ec2', region, aws_access_key_id=ACCESS_KEY, aws_secret_access_key=SECRET_KEY, )
delete_snapshot = ec2.describe_snapshots(Filters=tags_descrip)
for snap in delete_snapshot['Snapshots']:
print "Deleting snapshot %s" % snap['SnapshotId']
ec2.delete_snapshot(SnapshotId=snap['SnapshotId'])
错误
delete_snapshot = ec2.describe_snapshots(Filters=tags_descrip)
AttributeError: 'ec2.ServiceResource' object has no attribute 'describe_snapshots'
答案 0 :(得分:-2)
要在boto3中使用这些功能,您需要使用ec2客户端,可以像这样初始化:client = boto3.client('ec2')
。 (基本上,将ec2.*
替换为client.*