

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 在 Amazon Keyspaces CDC 直播中使用角色
<a name="using-service-linked-roles-CDC-streams"></a>

[Amazon Keyspaces（适用于 Apache Cassandra）使用 AWS Identity and Access Management (IAM) 服务相关角色。](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html#iam-term-service-linked-role)服务相关角色是一种独特类型的 IAM 角色，它与 Amazon Keyspaces 直接相关。服务相关角色由 Amazon Keyspaces 预定义，包括该服务代表您调用 AWS 其他服务所需的所有权限。

服务相关角色可让您更轻松地设置 Amazon Keyspaces，因为您不必手动添加必要的权限。Amazon Keyspaces 定义其服务相关角色的权限，除非另外定义，否则只有 Amazon Keyspaces 可以代入该角色。定义的权限包括信任策略和权限策略，而且权限策略不能附加到任何其它 IAM 实体。

您无法删除服务相关角色。

## Amazon Keyspaces 的服务相关角色权限
<a name="service-linked-role-permissions-CDC-streams"></a>

Amazon Keyspaces 使用名为 **AWSServiceRoleForAmazonKeyspacesCDC** 的服务相关角色来允许 Amazon Keyspaces CDC 直播代表您向您的 CloudWatch 账户发布指标。

 AWSServiceRoleForAmazonKeyspacesCDC 服务相关角色信任以下服务来代替该角色：
+ `cassandra-streams.amazonaws.com`

名为 [Keyspaces 的角色权限策略允许 CDCService RolePolicy](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/KeyspacesCDCServiceRolePolicy.html) Amazon Keyspaces 对命名空间中的资源完成以下操作： CloudWatch `AWS/Cassandra`
+ 操作：`*` 上的 `cloudwatch:PutMetricData`

   AWSServiceRoleForAmazonKeyspacesCDC对符合以下条件的所有资源提供权限:操作:PutMetricData cloudwatch:`"cloudwatch:namespace": "AWS/Cassandra"`.

有关 Keyspaces 的更多信息 CDCServiceRolePolicy，请参阅。[AWS 托管策略：Keyspaces CDCService RolePolicy](security-iam-awsmanpol.md#security-iam-awsmanpol-KeyspacesCDCServiceRolePolicy)

要为自动创建服务相关角色 CDC 的表启用 AWSService RoleForAmazonKeyspaces CDC 流，IAM 委托人需要以下权限。

```
{
    "Sid": "KeyspacesCDCServiceLinkedRole",
    "Effect": "Allow",
    "Action": "iam:CreateServiceLinkedRole",
    "Resource": "arn:aws:iam::*:role/aws-service-role/cassandra-streams.amazonaws.com/AWSServiceRoleForAmazonKeyspacesCDC",
    "Condition": {
    "StringLike": {
        "iam:AWSServiceName": "cassandra-streams.amazonaws.com"
    }
}
```

创建服务相关角色 AWSService RoleForAmazonKeyspaces CDC 的权限包含在`AmazonKeyspacesFullAccess`托管策略中。有关更多信息，请参阅 [AWS 托管策略： AmazonKeyspacesFullAccess](security-iam-awsmanpol.md#security-iam-awsmanpol-AmazonKeyspacesFullAccess)。

## 为 Amazon Keyspaces 创建服务相关角色
<a name="create-service-linked-role-CDC-streams"></a>

您无需为 Amazon Keyspaces CDC 直播手动创建服务相关角色。当您使用 AWS 管理控制台、CQL、或 API 在表上启用 Amazon Keyspaces CDC 流时 AWS ，Amazon Keyspaces 会为您创建服务相关角色。 AWS CLI

如果您删除该服务关联角色，然后需要再次创建，您可以使用相同流程在账户中重新创建此角色。当您为表启用 Amazon Keyspaces CDC 流时，Amazon Keyspaces 会再次为您创建与服务相关的角色。

## 为 Amazon Keyspaces 编辑服务相关角色
<a name="edit-service-linked-role-CDC-streams"></a>

Amazon Keyspaces 不允许您编辑 AWSService RoleForAmazonKeyspaces CDC 服务相关角色。创建服务关联角色后，您将无法更改角色的名称，因为可能有多种实体引用该角色。但是可以使用 IAM 编辑角色描述。有关更多信息，请参阅《IAM 用户指南》**中的[编辑服务关联角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/using-service-linked-roles.html#edit-service-linked-role)。

## Amazon Keyspaces 服务相关角色支持的区域
<a name="slr-regions-CDC-streams"></a>

Amazon Keyspaces 支持在该服务可用的所有区域中使用服务相关角色。有关更多信息，请参阅 [AWS 区域和端点](https://docs.aws.amazon.com/general/latest/gr/rande.html)。