如何向 Lambda 函数授予 Athena 查询权限?

Zha*_* Yi 5 amazon-web-services aws-lambda aws-security-group amazon-athena

我有一个 AWS Lambda 函数,用于查询Amazon Athena数据库。但在执行 Lambda 函数时出现权限错误:

调用 GetQueryExecution 操作时发生错误 (AccessDeniedException):用户:arn:aws:sts::773592622512:assumed-role/lambda_access-role/reddit_monitor 无权对资源执行:athena:GetQueryExecution:arn:aws:athena: ap-southeast-2:773592622512:工作组/主要: ClientError

我为 Lambda 函数创建了此策略:

  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": [
        "athena:StartQueryExecution"
      ],
      "Effect": "Allow",
      "Resource": "*"
    },
    {
      "Action": [
        "s3:*"
      ],
      "Effect": "Allow",
      "Resource": [
            "arn:aws:s3:::${var.athena-bucket}",
            "arn:aws:s3:::${var.athena-bucket}/*"
        ]
    } 
  ]
}
Run Code Online (Sandbox Code Playgroud)

我想知道为什么它仍然没有权限查询Athena?我在这里错过了什么吗?

Eag*_*eak 6

您授予athena:StartQueryExecution而不是athena:GetQueryExecution.