

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 使用 Amazon Keyspaces 的服務連結角色
<a name="using-service-linked-roles"></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)。服務連結角色是直接連結至 Amazon Keyspaces 的唯一 IAM 角色類型。服務連結角色由 Amazon Keyspaces 預先定義，並包含該服務代表您呼叫其他 AWS 服務所需的所有許可。

如需有關支援服務連結角色的其他 服務的資訊，請參閱[AWS 使用 IAM 的服務](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-services-that-work-with-iam.html)，並在**服務連結角色**欄中尋找具有**是**的服務。選擇具有連結的**是**，以檢視該服務的服務連結角色文件。

**Topics**
+ [使用 Amazon Keyspaces 應用程式自動擴展的角色](using-service-linked-roles-app-auto-scaling.md)
+ [使用 Amazon Keyspaces 多區域複寫的角色](using-service-linked-roles-multi-region-replication.md)
+ [使用 Amazon Keyspaces CDC 串流的角色](using-service-linked-roles-CDC-streams.md)

# 使用 Amazon Keyspaces 應用程式自動擴展的角色
<a name="using-service-linked-roles-app-auto-scaling"></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)。服務連結角色是直接連結至 Amazon Keyspaces 的唯一 IAM 角色類型。服務連結角色由 Amazon Keyspaces 預先定義，並包含該服務代表您呼叫其他 AWS 服務所需的所有許可。

服務連結角色可讓您更輕鬆地設定 Amazon Keyspaces，因為您不必手動新增必要的許可。Amazon Keyspaces 會定義其服務連結角色的許可，除非另有定義，否則只有 Amazon Keyspaces 可以擔任其角色。定義的許可包括信任政策和許可政策，且該許可政策無法附加至其他 IAM 實體。

您必須先刪除角色的相關資源，才能刪除服務連結角色。這可保護您的 Amazon Keyspaces 資源，因為您不會不小心移除存取資源的許可。

## Amazon Keyspaces 的服務連結角色許可
<a name="service-linked-role-permissions-app-auto-scaling"></a>

Amazon Keyspaces 使用名為 **AWSServiceRoleForApplicationAutoScaling\$1CassandraTable** 的服務連結角色，以允許 Application Auto Scaling 代表您呼叫 Amazon Keyspaces 和 Amazon CloudWatch。

AWSServiceRoleForApplicationAutoScaling\$1CassandraTable 服務連結角色信任下列服務擔任該角色：
+ `cassandra.application-autoscaling.amazonaws.com`

角色許可政策允許 Application Auto Scaling 對指定的 Amazon Keyspaces 資源完成下列動作：
+ 動作：`arn:*:cassandra:*:*:/keyspace/system/table/*` 上的 `cassandra:Select`
+ 動作：對資源 `arn:*:cassandra:*:*:/keyspace/system_schema/table/*` 執行 `cassandra:Select`
+ 動作：對資源 `arn:*:cassandra:*:*:/keyspace/system_schema_mcs/table/*` 執行 `cassandra:Select`
+ 動作：對資源 `arn:*:cassandra:*:*:"*"` 執行 `cassandra:Alter`

## 為 Amazon Keyspaces 建立服務連結角色
<a name="create-service-linked-role-app-auto-scaling"></a>

您不需要為 Amazon Keyspaces 自動擴展手動建立服務連結角色。當您使用 AWS 管理主控台、CQL、 AWS CLI或 AWS API 在資料表上啟用 Amazon Keyspaces 自動擴展時，Application Auto Scaling 會為您建立服務連結角色。

若您刪除此服務連結角色，之後需要再次建立，您可以在帳戶中使用相同程序重新建立角色。當您為資料表啟用 Amazon Keyspaces 自動擴展時，Application Auto Scaling 會再次為您建立服務連結角色。

**重要**  
 此服務連結角色可以顯示在您的帳戶，如果您於其他服務中完成一項動作時，可以使用支援此角色的功能。若要進一步了解，請參閱[我的 中出現的新角色 AWS 帳戶](https://docs.aws.amazon.com/IAM/latest/UserGuide/troubleshoot_roles.html#troubleshoot_roles_new-role-appeared)。

## 編輯 Amazon Keyspaces 的服務連結角色
<a name="edit-service-linked-role-app-auto-scaling"></a>

Amazon Keyspaces 不允許您編輯 AWSServiceRoleForApplicationAutoScaling\$1CassandraTable 服務連結角色。因為有各種實體可能會參考服務連結角色，所以您無法在建立角色之後變更角色名稱。然而，您可使用 IAM 來編輯角色描述。如需詳細資訊，請參閱《*IAM 使用者指南*》中的[編輯服務連結角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/using-service-linked-roles.html#edit-service-linked-role)。

## 刪除 Amazon Keyspaces 的服務連結角色
<a name="delete-service-linked-role-app-auto-scaling"></a>

若您不再使用需要服務連結角色的功能或服務，我們建議您刪除該角色。如此一來，您就沒有未主動監控或維護的未使用實體。不過，您必須先在帳戶中所有 的所有資料表上停用自動擴展 AWS 區域 ，才能手動刪除服務連結角色。若要在 Amazon Keyspaces 資料表上停用自動擴展，請參閱 [關閉資料表的 Amazon Keyspaces 自動擴展](autoscaling.turnoff.md)。

**注意**  
如果您嘗試修改資源時，Amazon Keyspaces 自動擴展正在使用該角色，則取消註冊可能會失敗。若此情況發生，請等待數分鐘後並再次嘗試操作。

**使用 IAM 手動刪除服務連結角色**

使用 IAM 主控台 AWS CLI、 或 AWS API 來刪除 AWSServiceRoleForApplicationAutoScaling\$1CassandraTable 服務連結角色。如需詳細資訊，請參閱《*IAM 使用者指南*》中的[刪除服務連結角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/using-service-linked-roles.html#delete-service-linked-role)。

**注意**  
若要刪除 Amazon Keyspaces 自動擴展所使用的服務連結角色，您必須先停用帳戶中所有資料表的自動擴展。

## Amazon Keyspaces 服務連結角色支援的區域
<a name="slr-regions-app-auto-scaling"></a>

Amazon Keyspaces 支援在提供服務的所有區域中使用服務連結角色。如需詳細資訊，請參閱 [Amazon Keyspaces 的服務端點](https://docs.aws.amazon.com/keyspaces/latest/devguide/programmatic.endpoints.html)。

# 使用 Amazon Keyspaces 多區域複寫的角色
<a name="using-service-linked-roles-multi-region-replication"></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)。服務連結角色是直接連結至 Amazon Keyspaces 的唯一 IAM 角色類型。服務連結角色由 Amazon Keyspaces 預先定義，並包含該服務代表您呼叫其他 AWS 服務所需的所有許可。

服務連結角色可讓您更輕鬆地設定 Amazon Keyspaces，因為您不必手動新增必要的許可。Amazon Keyspaces 會定義其服務連結角色的許可，除非另有定義，否則只有 Amazon Keyspaces 可以擔任其角色。定義的許可包括信任政策和許可政策，且該許可政策無法附加至其他 IAM 實體。

您必須先刪除角色的相關資源，才能刪除服務連結角色。這可保護您的 Amazon Keyspaces 資源，因為您不會不小心移除存取資源的許可。

## Amazon Keyspaces 的服務連結角色許可
<a name="service-linked-role-permissions-multi-region-replication"></a>

Amazon Keyspaces 使用名為 **AWSServiceRoleForAmazonKeyspacesReplication** 的服務連結角色，以允許 Amazon Keyspaces 代表您將新 AWS 區域 新增至金鑰空間，並將資料表及其所有資料和設定複寫至新區域。此角色也允許 Amazon Keyspaces 代表您複寫寫入至所有區域中的資料表。

AWSServiceRoleForAmazonKeyspacesReplication 服務連結角色信任下列服務擔任該角色：
+ `replication.cassandra.amazonaws.com`

名為 KeyspacesReplicationServiceRolePolicy 的角色許可政策允許 Amazon Keyspaces 完成下列動作：
+ 動作：`cassandra:Select`
+ 動作：`cassandra:SelectMultiRegionResource`
+ 動作：`cassandra:Modify`
+ 動作：`cassandra:ModifyMultiRegionResource`
+ 動作：`cassandra:AlterMultiRegionResource`
+ 動作：`application-autoscaling:RegisterScalableTarget`當您在佈建模式中將複本新增至單一區域資料表並啟用自動擴展時，Amazon Keyspaces 會使用應用程式自動擴展許可。
+ 動作：`application-autoscaling:DeregisterScalableTarget`
+ 動作：`application-autoscaling:DescribeScalableTargets`
+ 動作：`application-autoscaling:PutScalingPolicy`
+ 動作：`application-autoscaling:DescribeScalingPolicies`
+ 動作：`cassandra:Alter`
+ 動作：`cloudwatch:DeleteAlarms`
+ 動作：`cloudwatch:DescribeAlarms`
+ 動作：`cloudwatch:PutMetricAlarm`

雖然 Amazon Keyspaces 服務連結角色 AWSServiceRoleForAmazonKeyspacesReplication 提供政策中指定 Amazon Resource Name (ARN) "arn：\$1" 的許可："Action："，但 Amazon Keyspaces 會提供您帳戶的 ARN。

`AmazonKeyspacesFullAccess` 受管政策中包含建立服務連結角色 AWSServiceRoleForAmazonKeyspacesReplication 的許可。如需詳細資訊，請參閱[AWS 受管政策：AmazonKeyspacesFullAccess](security-iam-awsmanpol.md#security-iam-awsmanpol-AmazonKeyspacesFullAccess)。

您必須設定許可，以允許您的使用者、群組或角色建立、編輯或刪除服務連結角色。如需詳細資訊，請參閱 *IAM 使用者指南*中的[服務連結角色許可](https://docs.aws.amazon.com/IAM/latest/UserGuide/using-service-linked-roles.html#service-linked-role-permissions)。

## 為 Amazon Keyspaces 建立服務連結角色
<a name="create-service-linked-role-multi-region-replication"></a>

您無法手動建立服務連結角色。當您在 AWS 管理主控台、 AWS CLI或 AWS API 中建立多區域金鑰空間時，Amazon Keyspaces 會為您建立服務連結角色。

若您刪除此服務連結角色，之後需要再次建立，您可以在帳戶中使用相同程序重新建立角色。當您建立多區域金鑰空間時，Amazon Keyspaces 會再次為您建立服務連結角色。

## 編輯 Amazon Keyspaces 的服務連結角色
<a name="edit-service-linked-role-multi-region-replication"></a>

Amazon Keyspaces 不允許您編輯 AWSServiceRoleForAmazonKeyspacesReplication 服務連結角色。因為有各種實體可能會參考服務連結角色，所以您無法在建立角色之後變更角色名稱。然而，您可使用 IAM 來編輯角色描述。如需詳細資訊，請參閱《*IAM 使用者指南*》中的[編輯服務連結角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/using-service-linked-roles.html#edit-service-linked-role)。

## 刪除 Amazon Keyspaces 的服務連結角色
<a name="delete-service-linked-role-multi-region-replication"></a>

若您不再使用需要服務連結角色的功能或服務，我們建議您刪除該角色。如此一來，您就沒有未主動監控或維護的未使用實體。不過，您必須先刪除帳戶中的所有多區域金鑰空間， AWS 區域 才能手動刪除服務連結角色。

### 清除服務連結角色
<a name="service-linked-role-review-before-delete-multi-region-replication"></a>

您必須先刪除角色使用的任何多區域金鑰空間和資料表，才能使用 IAM 刪除服務連結角色。

**注意**  
如果您嘗試刪除資源時，Amazon Keyspaces 服務正在使用該角色，則刪除可能會失敗。若此情況發生，請等待數分鐘後並再次嘗試操作。

**刪除 AWSServiceRoleForAmazonKeyspacesReplication 使用的 Amazon Keyspaces 資源 （主控台）**

1. 登入 AWS 管理主控台，並在 https：//[https://console.aws.amazon.com/keyspaces/home](https://console.aws.amazon.com/keyspaces/home) 開啟 Amazon Keyspaces 主控台。

1. 從左側面板中選擇**金鑰空間**。

1. 從清單中選取所有多區域金鑰空間。

1. 選擇**刪除**確認刪除，然後選擇**刪除金鑰空間**。

您也可以使用下列任一方法，以程式設計方式刪除多區域金鑰空間。
+ Cassandra 查詢語言 (CQL) [DROP KEYSPACE](cql.ddl.keyspace.md#cql.ddl.keyspace.drop)陳述式。
+ CLI 的 [delete-keyspace](https://docs.aws.amazon.com/cli/latest/reference/keyspaces/delete-keyspace.html) AWS 操作。
+ Amazon Keyspaces API 的 [DeleteKeyspace](https://docs.aws.amazon.com/keyspaces/latest/APIReference/API_DeleteKeyspace.html) 操作。

### 手動刪除服務連結角色
<a name="slr-manual-delete-multi-region-replication"></a>

使用 IAM 主控台 AWS CLI、 或 AWS API 來刪除 AWSServiceRoleForAmazonKeyspacesReplication 服務連結角色。如需詳細資訊，請參閱《*IAM 使用者指南*》中的[刪除服務連結角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/using-service-linked-roles.html#delete-service-linked-role)。

## Amazon Keyspaces 服務連結角色支援的區域
<a name="slr-regions-multi-region-replication"></a>

Amazon Keyspaces 不支援在提供服務的每個區域中使用服務連結角色。您可以在下列區域中使用 AWSServiceRoleForAmazonKeyspacesReplication 角色。


****  

| 區域名稱 | 區域身分 | Amazon Keyspaces 的支援 | 
| --- | --- | --- | 
| 美國東部 (維吉尼亞北部) | us-east-1 | 是 | 
| 美國東部 (俄亥俄) | us-east-2 | 是 | 
| 美國西部 (加利佛尼亞北部) | us-west-1 | 是 | 
| 美國西部 (奧勒岡) | us-west-2 | 是 | 
| 亞太區域 (孟買) | ap-south-1 | 是 | 
| 亞太區域 (大阪) | ap-northeast-3 | 是 | 
| 亞太區域 (首爾) | ap-northeast-2 | 是 | 
| 亞太區域 (新加坡) | ap-southeast-1 | 是 | 
| 亞太區域 (雪梨) | ap-southeast-2 | 是 | 
| 亞太區域 (東京) | ap-northeast-1 | 是 | 
| 加拿大 (中部) | ca-central-1 | 是 | 
| 歐洲 (法蘭克福) | eu-central-1 | 是 | 
| 歐洲 (愛爾蘭) | eu-west-1 | 是 | 
| 歐洲 (倫敦) | eu-west-2 | 是 | 
| 歐洲 (巴黎) | eu-west-3 | 是 | 
| Africa (Cape Town) | af-south-1 | 是 | 
| 南美洲 (聖保羅) | sa-east-1 | 是 | 
| AWS GovCloud （美國東部） | us-gov-east-1 | 否 | 
| AWS GovCloud （美國西部） | us-gov-west-1 | 否 | 

# 使用 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)。服務連結角色是直接連結至 Amazon Keyspaces 的唯一 IAM 角色類型。服務連結角色由 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`

名為 [KeyspacesCDCServiceRolePolicy](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/KeyspacesCDCServiceRolePolicy.html) 的角色許可政策允許 Amazon Keyspaces 對 CloudWatch 命名空間 中的資源完成下列動作`AWS/Cassandra`：
+ 動作：`*` 上的 `cloudwatch:PutMetricData`

  AWSServiceRoleForAmazonKeyspacesCDC 會在符合下列條件的所有資源上提供許可：Action： cloudwatch：PutMetricData`"cloudwatch:namespace": "AWS/Cassandra"`。

如需 KeyspacesCDCServiceRolePolicy 的詳細資訊，請參閱 [AWS 受管政策：KeyspacesCDCServiceRolePolicy](security-iam-awsmanpol.md#security-iam-awsmanpol-KeyspacesCDCServiceRolePolicy)。

若要為會自動建立服務連結角色 AWSServiceRoleForAmazonKeyspacesCDC 的資料表啟用 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"
    }
}
```

`AmazonKeyspacesFullAccess` 受管政策中包含建立服務連結角色 AWSServiceRoleForAmazonKeyspacesCDC 的許可。如需詳細資訊，請參閱[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、 AWS CLI或 AWS API 的資料表上啟用 Amazon Keyspaces CDC 串流時，Amazon Keyspaces 會為您建立服務連結角色。

若您刪除此服務連結角色，之後需要再次建立，您可以在帳戶中使用相同程序重新建立角色。當您為資料表啟用 Amazon Keyspaces CDC 串流時，Amazon Keyspaces 會再次為您建立服務連結角色。

## 編輯 Amazon Keyspaces 的服務連結角色
<a name="edit-service-linked-role-CDC-streams"></a>

Amazon Keyspaces 不允許您編輯 AWSServiceRoleForAmazonKeyspacesCDC 服務連結角色。因為有各種實體可能會參考服務連結角色，所以您無法在建立角色之後變更角色名稱。然而，您可使用 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 Regions and endpoints](https://docs.aws.amazon.com/general/latest/gr/rande.html)。