本文介绍了AWS Lambda-在区域之间自动复制EC2快照?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一个Lambda函数(python),它将自动将已创建的快照复制到另一个区域。
I'd like to create a Lambda function (python) that will copy an already created snapshot to another region, automatically.
我已经联系了AWS支持,他们只是向我发送了用于RDS数据库的GitHub脚本。没有EC2快照复制脚本:(
I've reached out to AWS Support and they've only sent me GitHub scripts that were for RDS databases. No EC2 snapshot copy scripts :(
任何帮助都将非常有用!
Any help would be great!
谢谢。
推荐答案
是的,您可以使用boto3做到这一点
Yes you can do that with boto3
示例:
将快照从区域 us-east-1
复制到区域 eu-west-1
Example:
Copying snapshot from region us-east-1
to region eu-west-1
import boto3
def lambda_handler(event, context):
client = boto3.client('ec2')
client.copy_snapshot(SourceSnapshotId='snap-xxxxxx',
SourceRegion='us-east-1',
DestinationRegion='eu-west-1')
如果快照已加密,请添加 PresignedUrl
参数。
If the snapshot is encrypted, add PresignedUrl
parameter additionally.
这篇关于AWS Lambda-在区域之间自动复制EC2快照?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!