簡體   English   中英

AWS Athena 聯合查詢在 AWS Batch 中運行時出現權限錯誤

[英]AWS Athena Federated query gives permission error while running in AWS Batch

我已經在 Athena 中設置了 MySQL 數據源(它需要為 RDB 訪問創建 Lambda)並且可以在 Athena 控制台中成功運行聯合查詢 - 我可以在 RDB 表和 Athena/Glue 表之間進行連接(當引用 RDB 表時,它應該指定為<datasource_name>.<db_name>.<table_name> )並獲取結果。

現在我嘗試在我的 AWS Batch 應用程序中運行相同的聯合查詢,並收到以下錯誤:

The Amazon Athena query failed to run with error message: Amazon Athena experienced a permission error. Please provide proper permission and submitting the query again. If the issue reoccurs, contact AWS support for further assistance. You will not be charged for this query. We apologize for the inconvenience.

我可以在 AWS Batch 中成功運行僅使用 Athena/Glue 表的常規(非聯合)Athena 查詢。

我的 AWS Batch 作業定義使用ecsTaskExecutionRole作為“執行角色”和“作業角色 ARN”。

我已將以下策略添加到ecsTaskExecutionRoleecsInstanceRole中。 有沒有我遺漏的政策?

所有 Athena 操作的策略:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "athena:*"
            ],
            "Resource": [
                "arn:aws:athena:<my_region>:<my_acc_id>:*"
            ]
        }
    ]
}

所有 Glue 操作的策略:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "glue:*"
            ],
            "Resource": [
                "arn:aws:glue:<my_region>:<my_acc_id>:*"
            ]
        }
    ]
}

為訪問 MySQL 數據源而創建的 Lambda 的所有操作的策略:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "lambda:*"
            ],
            "Resource": [
                "arn:aws:lambda:<my_region>:<my_acc_id>:function:<my_lambda_name>:*"
            ]
        }
    ]
}

S3 存儲桶的策略 - 具有表數據的策略和用於存儲 Athena 輸出的策略:

{
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:AbortMultipartUpload",
                "s3:GetBucketLocation",
                "s3:GetObject",
                "s3:ListBucket",
                "s3:ListBucketMultipartUploads",
                "s3:PutObject"
            ],
            "Resource": [
                "arn:aws:s3:::<table_bucket>",
                "arn:aws:s3:::<table_bucket>/*",
                "arn:aws:s3:::<athena_output_bucket>",
                "arn:aws:s3:::<athena_output_bucket>/*"
            ]
        }
    ]
}

UPD。 為方便起見,根據此文檔添加了以下政策: https ://docs.aws.amazon.com/athena/latest/ug/federated-query-iam-access.html#fed-using-iam

    {
        "Effect": "Allow",
        "Action": "athena:ListWorkGroups",
        "Resource": "*"
    }

並將此資源"arn:aws:s3:::<athena_output_bucket>/athena-spill*" (溢出桶與雅典娜輸出桶相同)添加到 S3 策略。 仍然沒有成功

找出原因 - 最后應指定 Lambda 資源而不使用通配符:

arn:aws:lambda:<my_region>:<my_acc_id>:function:<my_lambda_name>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM