

# 允许使用 Athena 访问机器学习
<a name="machine-learning-iam-access"></a>

必须允许运行 Athena ML 查询的 IAM 主体对其使用的 Sagemaker 端点执行 `sagemaker:invokeEndpoint` 操作。在附加到用户身份且基于身份的权限策略中包括类似于下面的策略语句。此外，附加对 Athena 操作授予完全访问权限的 [AWS 托管策略：AmazonAthenaFullAccess](security-iam-awsmanpol.md#amazonathenafullaccess-managed-policy)，或者附加允许操作子集的已修改内联策略。

将示例中的 `arn:aws:sagemaker:region:AWSAcctID:ModelEndpoint` 替换为要在查询中使用的模型端点的 ARN。有关更多信息，请参阅《服务授权参考》中的 [Actions, resources, and condition keys for SageMaker AI](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonsagemaker.html)**。

```
{
            "Effect": "Allow",
            "Action": [
                "sagemaker:invokeEndpoint"
            ],
            "Resource": "arn:aws:sagemaker:us-west-2:123456789012:workteam/public-crowd/default"
}
```

每当您使用 IAM 策略时，请确保遵循 IAM 最佳实践。有关更多信息，请参阅《[IAM 用户指南](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html)》中的 *IAM 安全最佳实践*。