aws lambda function getting access denied when getObject from s3

后端 未结 12 1578
离开以前
离开以前 2020-12-08 06:44

I am getting an acccess denied error from S3 AWS service on my Lambda function.

This is the code:

// dependencies
var async = require(\'async\');
var         


        
12条回答
  •  温柔的废话
    2020-12-08 06:59

    I tried to execute a basic blueprint Python lambda function [example code] and I had the same issue. My execition role was lambda_basic_execution

    I went to S3 > (my bucket name here) > permissions .

    Because I'm beginner, I used the Policy Generator provided by Amazon rather than writing JSON myself: http://awspolicygen.s3.amazonaws.com/policygen.html my JSON looks like this:

    {
        "Id": "Policy153536723xxxx",
        "Version": "2012-10-17",
        "Statement": [
            {
                "Sid": "Stmt153536722xxxx",
                "Action": [
                    "s3:GetObject"
                ],
                "Effect": "Allow",
                "Resource": "arn:aws:s3:::tokabucket/*",
                "Principal": {
                    "AWS": [
                        "arn:aws:iam::82557712xxxx:role/lambda_basic_execution"
                    ]
                }
            }
        ]
    

    And then the code executed nicely:

提交回复
热议问题