sla*_*eff 0 json amazon-ec2 amazon-web-services amazon-iam aws-lambda
我正在尝试运行一个测试函数,以便在 AWS 的 2 个区域之间复制单个快照(将来我想自动化它)。但是当我运行测试时它会抛出一个错误
"errorType": "ClientError", "errorMessage": "调用 CopySnapshot 操作时发生错误 (UnauthorizedOperation): 您无权执行此操作。"
这是我的 IAM 的样子:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:*"
],
"Resource": "arn:aws:logs:*:*:*"
},
{
"Effect": "Allow",
"Action": "ec2:Describe*",
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"ec2:CreateSnapshot",
"ec2:DeleteSnapshot",
"ec2:CreateTags",
"ec2:ModifySnapshotAttribute",
"ec2:ResetSnapshotAttribute"
],
"Resource": [
"*"
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
这是函数:
import boto3
def lambda_handler(event, context):
client = boto3.client('ec2')
client.copy_snapshot(SourceSnapshotId='snap-xxxxxxxxxxxxxxxxxxxxx',
SourceRegion='us-central-1',
DestinationRegion='eu-west-3')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1828 次 |
| 最近记录: |