

# 使用 AWS CLI 的 Amazon EMR on EKS 示例
<a name="cli_emr-containers_code_examples"></a>

以下代码示例演示如何通过将 AWS Command Line Interface与 Amazon EMR on EKS 结合使用，来执行操作和实现常见场景。

*操作是大型程序的代码摘录*，必须在上下文中运行。您可以通过操作了解如何调用单个服务函数，还可以通过函数相关场景的上下文查看操作。

每个示例都包含一个指向完整源代码的链接，您可以从中找到有关如何在上下文中设置和运行代码的说明。

**Topics**
+ [操作](#actions)

## 操作
<a name="actions"></a>

### `update-role-trust-policy`
<a name="emr-containers_UpdateRoleTrustPolicy_cli_topic"></a>

以下代码示例演示了如何使用 `update-role-trust-policy`。

**AWS CLI**  
**更新要与 Amazon EMR on EKS 结合使用的 IAM 角色的信任策略**  
此示例命令更新名为 **example\$1iam\$1role** 的角色的信任策略，以便它可以与名为 **example\$1cluster** 的 EKS 集群中具有 **example\$1namespace** 命名空间的 Amazon EMR on EKS 结合使用。  
命令:  

```
aws emr-containers update-role-trust-policy \
    --cluster example_cluster \
    --namespace example_namespace \
    --role-name example_iam_role
```
输出：  

```
If the trust policy has already been updated, then the output will be:
Trust policy statement already exists for role example_iam_role. No
changes were made!

If the trust policy has not been updated yet, then the output will be:
Successfully updated trust policy of role example_iam_role.
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [UpdateRoleTrustPolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/emr-containers/update-role-trust-policy.html)。