简体   繁体   English

AWS Lambda-在区域之间自动复制EC2快照?

[英]AWS Lambda - Copy EC2 Snapshot automatically between regions?

I'd like to create a Lambda function (python) that will copy an already created snapshot to another region, automatically. 我想创建一个Lambda函数(python),它将自动将已创建的快照复制到另一个区域。

I've reached out to AWS Support and they've only sent me GitHub scripts that were for RDS databases. 我已经联系了AWS Support,他们只是向我发送了用于RDS数据库的GitHub脚本。 No EC2 snapshot copy scripts :( 没有EC2快照复制脚本:(

Any help would be great! 任何帮助将是巨大的!

Thank you. 谢谢。

Yes you can do that with boto3 是的,您可以使用boto3做到这一点

Example: Copying snapshot from region us-east-1 to region eu-west-1 Example:将快照从区域us-east-1复制到区域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')

If the snapshot is encrypted, add PresignedUrl parameter additionally. 如果快照已加密, PresignedUrl另外添加PresignedUrl参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM