AWS Lambda - Copy EC2 Snapshot automatically betwe

2019-09-14 01:04发布

I'd like to create a Lambda function (python) that will copy an already created snapshot to another region, automatically.

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!

Thank you.

1条回答
smile是对你的礼貌
2楼-- · 2019-09-14 01:36

Yes you can do that with boto3

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')

If the snapshot is encrypted, add PresignedUrl parameter additionally.

查看更多
登录 后发表回答