

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

# 使用 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)。