

# 在 Athena 中创建和使用数据来源的权限
<a name="connect-to-a-data-source-permissions"></a>

## 没有 Lambda 权限的 AWS Glue Data Catalog 联合连接器
<a name="connect-to-a-data-source-permissions-managed"></a>
+ **调用 Athena API 进行连接器管理和查询的 IAM 主体权限**
  + **Amazon Athena 访问权限**：AmazonAthenaFullAccess 托管策略提供对 Amazon Athena 的完全访问权限，以及对启用查询、写入结果和数据管理所需依赖项的限定访问权限。有关更多信息，请参阅《AWS 托管式策略参考指南》中的 [AmazonAthenaFullAccess](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonAthenaFullAccess.html)。
  + **AWS Glue 连接管理**：创建和管理 AWS Glue 连接对象的权限。

    ```
    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "glue:GetConnection",
                    "glue:CreateConnection",
                    "glue:DeleteConnection",
                    "glue:UpdateConnection"
                ],
                "Resource": "*"
            }
        ]
    }
    ```
**注意**  
为简洁起见，示例策略使用了 `"Resource": "*"`。对于生产环境，应尽可能将权限范围限定为特定资源。
  + **AWS Lake Formation 访问权限**：创建 AWS Glue 目录和使用精细访问控制的权限。

------
#### [ JSON ]

****  

    ```
    {
      "Version":"2012-10-17",		 	 	 
      "Statement": [
        {
          "Effect": "Allow",
          "Action": [
            "lakeformation:RegisterResource",
            "iam:ListRoles",
            "glue:CreateCatalog",
            "glue:GetCatalogs",
            "glue:GetCatalog"
          ],
          "Resource": "*"
        }
      ]
    }
    ```

------
+ **Glue 数据目录 IAM 角色**
  +  本节介绍 Athena 配置基础设施和查询数据来源所需的权限。Amazon Athena 联合查询需要在传递至 **Glue 数据目录 IAM 角色**的角色中拥有以下权限。
**注意**  
当连接到 VPC 中的数据来源时，Athena 会在您的账户中，在指定 VPC 内创建一个弹性网络接口（ENI）。IAM 角色需要 EC2 权限来创建、描述和删除此网络接口。

    ```
    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "glue:ManagedConnector",
                    "s3:PutObject",
                    "secretsmanager:DescribeSecret",
                    "secretsmanager:GetSecretValue",
                    "secretsmanager:PutSecretValue",
                    "ec2:CreateNetworkInterface",
                    "ec2:DeleteNetworkInterface",
                    "ec2:DescribeNetworkInterfaces",
                    "ec2:DescribeSubnets",
                    "ec2:DescribeSecurityGroups",
                    "ec2:DescribeVpcs",
                    "dynamodb:DescribeTable",
                    "dynamodb:ListTables",
                    "dynamodb:Scan",
                    "dynamodb:Query",
                    "dynamodb:GetItem",
                    "dynamodb:BatchGetItem"
                ],
                "Resource": "*"
            }
        ]
    }
    ```
**注意**  
为简洁起见，示例策略使用了 `"Resource": "*"`。对于生产环境，应尽可能将权限范围限定为特定资源。例如，将 Secrets Manager 权限的范围限定为特定的密钥 ARN。  
**权限说明**    
[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/athena/latest/ug/connect-to-a-data-source-permissions.html)

## 具有 Lambda 权限的 AWS Glue Data Catalog 联合连接器
<a name="connect-to-a-data-source-permissions-lambda"></a>
+ **调用 Athena API 进行连接器管理和查询的 IAM 主体权限**
  + **Amazon Athena 访问权限**：AmazonAthenaFullAccess 托管策略提供对 Amazon Athena 的完全访问权限，以及对启用查询、写入结果和数据管理所需依赖项的限定访问权限。有关更多信息，请参阅《AWS 托管式策略参考指南》中的 [AmazonAthenaFullAccess](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonAthenaFullAccess.html)。
  + **连接器管理权限**：使用基于 Lambda 的连接器时，需要以下权限才能调用 Athena DataCatalog API。请参阅[创建连接器和 Athena 目录所需的权限](athena-catalog-access.md)。
  + **AWS Lake Formation 访问权限（如果使用 Lake Formation）**：创建 AWS Glue 目录和使用精细访问控制的权限。

------
#### [ JSON ]

****  

    ```
    {
      "Version":"2012-10-17",		 	 	 
      "Statement": [
        {
          "Effect": "Allow",
          "Action": [
            "lakeformation:RegisterResource",
            "iam:ListRoles",
            "glue:CreateCatalog",
            "glue:GetCatalogs",
            "glue:GetCatalog"
          ],
          "Resource": "*"
        }
      ]
    }
    ```

------

## Athena 数据目录联合连接器权限
<a name="connect-to-a-data-source-permissions-legacy"></a>
+ **调用 Athena API 进行连接器管理和查询的 IAM 主体权限**
  + **Amazon Athena 访问权限**：AmazonAthenaFullAccess 托管策略提供对 Amazon Athena 的完全访问权限，以及对启用查询、写入结果和数据管理所需依赖项的限定访问权限。有关更多信息，请参阅《AWS 托管式策略参考指南》中的 [AmazonAthenaFullAccess](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonAthenaFullAccess.html)。
  + **连接器管理权限**：使用基于 Lambda 的连接器时，需要以下权限才能调用 Athena DataCatalog API。请参阅[创建连接器和 Athena 目录所需的权限](athena-catalog-access.md)。