AWS S3 Lambda访问被拒绝

时间:2016-09-21 16:24:14

标签: python amazon-web-services amazon-s3 amazon-iam aws-lambda

尝试关注this tutorial并在运行Lambda时不断收到“拒绝访问”。 Lambda是默认的s3-python-get-object

lambda的角色是

{
"Version": "2012-10-17",
"Statement": [
    {
        "Effect": "Allow",
        "Action": [
            "s3:GetObject",
            "s3:DeleteObject"
        ],
        "Resource": [
            "arn:aws:s3:::*"
        ]
    }
]
}

用户具有管理员权限。我只是不明白为什么会出错。

1 个答案:

答案 0 :(得分:0)

来自docs

If the object you request does not exist, the error Amazon S3 returns depends on whether you also have the s3:ListBucket permission.

If you have the s3:ListBucket permission on the bucket, Amazon S3 returns an HTTP status code 404 ("no such key") error.
If you don’t have the s3:ListBucket permission, Amazon S3 returns an HTTP status code 403 ("access denied") error.

上面的代码似乎适合您的操作。 请确保您拥有要调用的密钥或添加s3:ListBucket权限,以确保出现此类错误。