Athena 查询失败:"Insufficient permissions to execute the query"
Athena query fails with: "Insufficient permissions to execute the query"
我正在编写一个 lambda 函数,它应该启动对 Athena 的查询,当我执行 start_query_execution 时它成功了,但是当我稍后尝试获取查询状态时,我看到以下内容:
'Status': {'State': 'FAILED', 'StateChangeReason': 'Insufficient permissions to execute the query. User: arn:aws:sts::XXXXXXXXXXXX:assumed-role/test_role/test-audit is not authorized to perform: glue:GetTable on resource: arn:aws:glue:us-east-1:XXXXXXXXXXXX:catalog ', 'SubmissionDateTime': datetime.datetime(2019, 9, 16, 17, 13, 18, 749000, tzinfo=tzlocal()), 'CompletionDateTime': datetime.datetime(2019, 9, 16, 17, 13, 31, 197000, tzinfo=tzlocal())}
lambda 分配了一个具有以下权限的 IAM 角色:
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"s3:*",
"dynamodb:*",
"kinesis:*",
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"cloudwatch:PutMetricData",
"athena:*",
"glue:*",
"redshift:*"
],
"Resource": [
"*"
],
"Effect": "Allow"
}
]
}
根据角色,我认为它可以使用 Athena 对该帐户中的任何 S3 存储桶做任何它需要做的事情,但它失败了。所有 S3 资源都在与执行代码的 lambda 以及 athena table 相同的帐户中。开始查询配置如下:
response = athena.start_query_execution(
QueryString=query,
ClientRequestToken=hashlib.md5(query.encode()).hexdigest(),
QueryExecutionContext={
'Database': 'test'
},
ResultConfiguration={
'OutputLocation': 's3://athena-test.query.results/test/',
'EncryptionConfiguration': {
'EncryptionOption': 'SSE_S3'
}
}
)
如有任何见解,我们将不胜感激。
谢谢!
指定权限可能会有帮助。
我这样试过
- Effect: Allow
Action:
- "glue:GetTable"
Resource:
- "*"
在资源中您也可以指定存储桶名称。
事实证明,除了 AWS 控制台中的陈旧行为外,没有任何问题。
我正在编写一个 lambda 函数,它应该启动对 Athena 的查询,当我执行 start_query_execution 时它成功了,但是当我稍后尝试获取查询状态时,我看到以下内容:
'Status': {'State': 'FAILED', 'StateChangeReason': 'Insufficient permissions to execute the query. User: arn:aws:sts::XXXXXXXXXXXX:assumed-role/test_role/test-audit is not authorized to perform: glue:GetTable on resource: arn:aws:glue:us-east-1:XXXXXXXXXXXX:catalog ', 'SubmissionDateTime': datetime.datetime(2019, 9, 16, 17, 13, 18, 749000, tzinfo=tzlocal()), 'CompletionDateTime': datetime.datetime(2019, 9, 16, 17, 13, 31, 197000, tzinfo=tzlocal())}
lambda 分配了一个具有以下权限的 IAM 角色:
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"s3:*",
"dynamodb:*",
"kinesis:*",
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"cloudwatch:PutMetricData",
"athena:*",
"glue:*",
"redshift:*"
],
"Resource": [
"*"
],
"Effect": "Allow"
}
]
}
根据角色,我认为它可以使用 Athena 对该帐户中的任何 S3 存储桶做任何它需要做的事情,但它失败了。所有 S3 资源都在与执行代码的 lambda 以及 athena table 相同的帐户中。开始查询配置如下:
response = athena.start_query_execution(
QueryString=query,
ClientRequestToken=hashlib.md5(query.encode()).hexdigest(),
QueryExecutionContext={
'Database': 'test'
},
ResultConfiguration={
'OutputLocation': 's3://athena-test.query.results/test/',
'EncryptionConfiguration': {
'EncryptionOption': 'SSE_S3'
}
}
)
如有任何见解,我们将不胜感激。
谢谢!
指定权限可能会有帮助。
我这样试过
- Effect: Allow
Action:
- "glue:GetTable"
Resource:
- "*"
在资源中您也可以指定存储桶名称。
事实证明,除了 AWS 控制台中的陈旧行为外,没有任何问题。