

 **帮助改进此页面** 

要帮助改进本用户指南，请选择位于每个页面右侧窗格中的**在 GitHub 上编辑此页面**链接。

# IAM 故障排除
<a name="security-iam-troubleshoot"></a>

本主题介绍将 Amazon EKS 与 IAM 结合使用时可能遇到的一些常见错误以及相应的错误处理方式。

## AccessDeniedException
<a name="iam-error"></a>

如果您在调用 Amazon API 操作时收到 `AccessDeniedException`，则表明您使用的 [IAM 主体](https://docs.amazonaws.cn/IAM/latest/UserGuide/id_roles.html#iam-term-principal)凭证不具有发起该调用所需的权限。

```
An error occurred (AccessDeniedException) when calling the DescribeCluster operation:
User: arn:aws-cn:iam::111122223333:user/user_name is not authorized to perform:
eks:DescribeCluster on resource: arn:aws-cn:eks:region:111122223333:cluster/my-cluster
```

在前述示例消息中，用户没有权限调用 Amazon EKS `DescribeCluster` API 操作。要为 IAM 主体提供 Amazon EKS 管理员权限，请参阅[Amazon EKS 基于身份的策略示例](security-iam-id-based-policy-examples.md)。

有关 IAM 的一般信息，请参阅 *IAM 用户指南*中的[使用策略控制访问](https://docs.amazonaws.cn/IAM/latest/UserGuide/access_controlling.html)。

## 无法在**计算**选项卡上看到**节点**，或在**资源**选项卡上看到任何内容，您将在 Amazon Web Services 管理控制台 中收到错误
<a name="security-iam-troubleshoot-cannot-view-nodes-or-workloads"></a>

您可能会看到一条内容为“`Your current user or role does not have access to Kubernetes objects on this EKS cluster`”的控制台错误消息。确保您将 Amazon Web Services 管理控制台 与其结合使用的 [IAM 主体](https://docs.amazonaws.cn/IAM/latest/UserGuide/id_roles.html#iam-term-principal)用户具有必要的权限。有关更多信息，请参阅 [所需的权限](view-kubernetes-resources.md#view-kubernetes-resources-permissions)。

## aws-auth `ConfigMap` 不授予对集群的访问权限
<a name="security-iam-troubleshoot-configmap"></a>

[Amazon IAM 身份验证器](https://github.com/kubernetes-sigs/aws-iam-authenticator)不允许在 `ConfigMap` 中使用角色 ARN 中的路径。因此，在指定 `rolearn` 之前，请删除路径。例如，将 ` arn:aws-cn:iam::111122223333:role/team/developers/eks-admin ` 更改为 ` arn:aws-cn:iam::111122223333:role/eks-admin `。

## 我无权执行 iam:PassRole
<a name="security-iam-troubleshoot-passrole"></a>

如果您收到一个错误，表明您无权执行 `iam:PassRole` 操作，则必须更新策略以允许您将角色传递给 Amazon EKS。

有些 Amazon 服务允许您将现有角色传递到该服务，而不是创建新服务角色或服务相关角色。为此，您必须具有将角色传递到服务的权限。

当名为 `marymajor` 的 IAM 用户尝试使用控制台在 Amazon EKS 中执行操作时，会发生以下示例错误。但是，服务必须具有服务角色所授予的权限才可执行此操作。Mary 不具有将角色传递到服务的权限。

```
User: {arn-aws}iam::123456789012:user/marymajor is not authorized to perform: iam:PassRole
```

在这种情况下，必须更新 Mary 的策略以允许她执行 `iam:PassRole` 操作。

如果您需要帮助，请联系 Amazon 管理员。您的管理员是提供登录凭证的人。

## 我希望允许我的Amazon账户以外的人访问我的 Amazon EKS 资源
<a name="security-iam-troubleshoot-cross-account-access"></a>

您可以创建一个角色，以便其他账户中的用户或您组织外的人员可以使用该角色来访问您的资源。您可以指定谁值得信赖，可以代入角色。对于支持基于资源的策略或访问控制列表（ACL）的服务，您可以使用这些策略向人员授予对您的资源的访问权。

要了解更多信息，请参阅以下内容：
+ 要了解 Amazon EKS 是否支持这些功能，请参阅 [Amazon EKS 如何与 IAM 配合使用](security-iam-service-with-iam.md)。
+ 要了解如何为您拥有的 Amazon 账户中的资源提供访问权限，请参阅 *IAM 用户指南*中的[为您拥有的另一个 Amazon 账户中的 IAM 用户提供访问权限](https://docs.amazonaws.cn/IAM/latest/UserGuide/id_roles_common-scenarios_aws-accounts.html)。
+ 要了解如何为第三方 Amazon 账户提供您的资源的访问权限，请参阅*IAM 用户指南中的 [ 为第三方拥有的 Amazon](https://docs.amazonaws.cn/IAM/latest/UserGuide/id_roles_common-scenarios_third-party.html) 账户提供访问权限*。
+ 要了解如何通过身份联合验证提供访问权限，请参阅《IAM 用户指南》**中的[为经过外部身份验证的用户（身份联合验证）提供访问权限](https://docs.amazonaws.cn/IAM/latest/UserGuide/id_roles_common-scenarios_federated-users.html)。
+ 要了解使用角色和基于资源的策略进行跨账户访问之间的差别，请参阅《IAM 用户指南》**中的 [IAM 中的跨账户资源访问](https://docs.amazonaws.cn/IAM/latest/UserGuide/access_policies-cross-account-resource-access.html)。

## 容器组（pod）容器收到以下错误：`An error occurred (SignatureDoesNotMatch) when calling the GetCallerIdentity operation: Credential should be scoped to a valid region`
<a name="security-iam-troubleshoot-wrong-sts-endpoint"></a>

如果应用程序明确向 Amazon STS 全局端点（`https://sts.amazonaws.com`）提出要求并且 Kubernetes 服务账户已配置为使用区域端点，您的容器会收到此错误。您可以使用以下选项之一解决问题：
+ 更新应用程序代码以删除对 Amazon STS 全局端点的显式调用。
+ 更新应用程序代码以明确调用区域端点，例如 `https://sts.us-west-2.amazonaws.com`。您的应用程序应内置冗余功能，以便在该 Amazon 区域的服务出现故障时选择其它 Amazon 区域。有关更多信息，请参阅《IAM 用户指南》中的[在 Amazon 区域中管理 Amazon STS](https://docs.amazonaws.cn/IAM/latest/UserGuide/id_credentials_temp_enable-regions.html)。
+ 将服务账户配置为使用全局端点。默认情况下，集群使用区域端点。有关更多信息，请参阅 [为服务账户配置 Amazon Security Token Service 端点](configure-sts-endpoint.md)。