我想定期创建EBS快照,并将其转移到另一个AWS账户。有没有办法自动化这个过程?
我知道它可以手动完成,如How to copy EC2 snapshots to another amazon account中所述。
答案 0 :(得分:3)
文档中描述了这一点:Sharing an Amazon EBS Snapshot
使用aws CLI进行翻译的步骤是
私下分享:
aws ec2 modify-snapshot-attribute \
--snapshot-id "snap-xxxxx" \
--create-volume-permission "{
\"Add\": [
{
\"UserId\": \"XXXXXXX\"
}
]
}"
公开分享:
aws ec2 modify-snapshot-attribute \
--snapshot-id "snap-xxxxx" \
--create-volume-permission "{
\"Add\": [
{
\"Group\": \"all\"
}
]
}"
复制快照
aws ec2 copy-snapshot \
--region "target-region"
--source-region "source" \
--source-snapshot-id "snap-xxxxx" \
--description "Example Description"
小心不要与destination-region
--destination-region (string)
The destination region to use in the PresignedUrl parameter of a
snapshot copy operation. This parameter is only valid for specifying
the destination region in a PresignedUrl parameter, where it is
required.
NOTE:
copy-snapshot sends the snapshot copy to the regional endpoint
that you send the HTTP request to, such as ec2.us-east-1.amazon-
aws.com (in the AWS CLI, this is specified with the --region
parameter or the default region in your AWS configuration file).
答案 1 :(得分:0)
最简单的方法是修改允许其他帐户访问快照的权限,而不是将快照“转移”到其他帐户。
这样,快照只存储一次而不是支付双重存储费用。
快照创建可以是scheduled via Amazon CloudWatch Events。但是,这不允许您设置权限。因此,您需要: