代码之家  ›  专栏  ›  技术社区  ›  Harry

如何修复未授权执行的问题:dynamodb:Scan error

  •  1
  • Harry  · 技术社区  · 6 年前

    调用扫描操作:用户: arn:aws:sts::747857903140:假定角色/code starworker helpbot Lambda/awscodestar-helpbot-Lambda-FindService-1L7IH17742JLR arn:aws:dynamodb:us-east-1:747857903140:表/HelpBot“

    这在我的SAM模板中:

    FindService:
        Type: AWS::Serverless::Function
        Properties:
          Handler: find_service.handler
          Runtime: python3.6
          Role:
            Fn::ImportValue:
              !Join ['-', [!Ref 'ProjectId', !Ref 'AWS::Region', 'LambdaTrustRole']]
          Policies:
            - AmazonDynamoDBFullAccess
    

    1 回复  |  直到 6 年前
        1
  •  2
  •   Tom    6 年前

    根据 this SAM CloudFormation doc :

    如果设置了Role属性,则此属性没有意义。

    后者看起来像这样:

      Policies:
        Version: '2012-10-17'
        Statement:
        - Effect: Allow
          Action:
          - dynamodb:Scan
          Resource: arn:aws:dynamodb:region:account-id:table/table-name
        - Effect: Allow
          Action:
          - ...
          Resource: ...
    
        2
  •  0
  •   M.Namjo    4 年前

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "dynamodb:BatchGetItem",
                    "dynamodb:GetItem",
                    "dynamodb:Query",
                    "dynamodb:Scan",
                    "dynamodb:BatchWriteItem",
                    "dynamodb:PutItem",
                    "dynamodb:UpdateItem"
               ],
                "Resource": "arn:aws:dynamodb:eu-west-1:77777:table/order"
                },
               {
                "Effect": "Allow",
                "Action": [
                    "dynamodb:BatchGetItem",
                    "dynamodb:GetItem",
                    "dynamodb:Query",
                    "dynamodb:Scan",
                    "dynamodb:BatchWriteItem",
                    "dynamodb:PutItem",
                    "dynamodb:UpdateItem"
                ],
                "Resource": "arn:aws:dynamodb:eu-west-1:777:table/ExecutionId"
            },
            {
                "Effect": "Allow",
                "Action": "logs:CreateLogGroup",
                "Resource": "arn:aws:logs:eu-west-1:777777:*"
            },
            {
                "Effect": "Allow",
                "Action": [
                    "logs:CreateLogStream",
                    "logs:PutLogEvents"
                ],
                "Resource": [
                    "arn:aws:logs:eu-west-1:777777:log-group:/aws/lambda/MyReport:*"
                ]
            }
        ]
    }