[英]Copying AWS Snapshots using boto3
我有用于源和目标区域的一段代码。 我设法对所有快照数据进行了响应,但是我无法仅对“ SnapshotId”进行过滤并复制响应。
import boto3
REGIONS = ['eu-central-1', 'eu-west-3']
SOURCEREG = boto3.client('ec2', region_name='eu-central-1')
DISTREG = boto3.client('ec2', region_name='eu-west-3')
response = SOURCEREG.describe_snapshots()
print(response)
在这种情况下,我收到一个类似于{'OwnerId':'xxxxxxx','StartTime':datetime.xxxxxxxx,'SnapshotId':'snap-xxxxxxxxxx“等的json响应。
如何过滤此输出并复制快照?
参考: describe_snapshots和copy_snapshot
import boto3
conn = boto3.client('ec2', region_name='eu-central-1')
response = conn.describe_snapshots()
for snapshots in response['Snapshots']:
print('Copying Snapshot -> ' + snapshots['SnapshotId'])
copy_response = conn.copy_snapshot(
Description='Snapshot copied from' + snapshots['SnapshotId'],
DestinationRegion='eu-central-1',
SourceRegion='eu-west-3',
SourceSnapshotId=snapshots['SnapshotId'],
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.