

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

# 靜態加密：如何使用客戶自管金鑰來加密 Amazon Keyspaces 中的表格
<a name="encryption.customermanaged"></a>

您可以使用 主控台或 CQL 陳述式， AWS KMS key 為新資料表指定 ，並更新 Amazon Keyspaces 中現有資料表的加密金鑰。下列主題概述如何實作新資料表和現有資料表的客戶受管金鑰。

**Topics**
+ [先決條件：使用 建立客戶受管金鑰， AWS KMS 並將許可授予 Amazon Keyspaces](#encryption.createCMKMS)
+ [步驟 3：指定新資料表的客戶受管金鑰](#encryption.tutorial-creating)
+ [步驟 4：更新現有資料表的加密金鑰](#encryption.tutorial-update)
+ [步驟 5：在日誌中使用 Amazon Keyspaces 加密內容](#encryption-context)
+ [步驟 6：使用 設定監控 AWS CloudTrail](#encryption-cmk-trail)

## 先決條件：使用 建立客戶受管金鑰， AWS KMS 並將許可授予 Amazon Keyspaces
<a name="encryption.createCMKMS"></a>

您必須先在 AWS Key Management Service (AWS KMS) 中建立金鑰，然後授權 Amazon Keyspaces 使用該金鑰，才能使用[客戶受管金鑰](encryption.howitworks.md#customer-managed)來保護 Amazon Keyspaces 資料表。

### 步驟 1：使用 建立客戶受管金鑰 AWS KMS
<a name="encryption-create-key"></a>

若要建立用於保護 Amazon Keyspaces 資料表的客戶受管金鑰，您可以遵循使用主控台或 AWS API [建立對稱加密 KMS 金鑰](https://docs.aws.amazon.com/kms/latest/developerguide/create-keys.html#create-symmetric-cmk)中的步驟。

### 步驟 2：授權使用客戶受管金鑰
<a name="encryption-authz"></a>

在您可以選擇[客戶受管金鑰](encryption.howitworks.md#customer-managed)來保護 Amazon Keyspaces 資料表之前，該客戶受管金鑰上的政策必須授予 Amazon Keyspaces 代表您使用它的許可。您可以完全控制客戶受管金鑰上的政策和授予。您可以在[金鑰政策](https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html)、[IAM 政策](https://docs.aws.amazon.com/kms/latest/developerguide/iam-policies.html)或[授予](https://docs.aws.amazon.com/kms/latest/developerguide/grants.html)中提供這些許可。

Amazon Keyspaces 不需要額外的授權，即可使用預設值[AWS 擁有的金鑰](encryption.howitworks.md#keyspaces-owned)來保護您 AWS 帳戶中的 Amazon Keyspaces 資料表。

下列主題說明如何使用 IAM 政策和授予來設定必要的許可，以允許 Amazon Keyspaces 資料表使用客戶受管金鑰。

**Topics**
+ [客戶受管金鑰的金鑰政策](#encryption-customer-managed-policy)
+ [範例金鑰政策](#encryption-customer-managed-policy-sample)
+ [使用授予授權 Amazon Keyspaces](#encryption-grants)

#### 客戶受管金鑰的金鑰政策
<a name="encryption-customer-managed-policy"></a>

當您選取[客戶受管金鑰](encryption.howitworks.md#customer-managed)來保護 Amazon Keyspaces 資料表時，Amazon Keyspaces 會取得代表進行選取之主體使用客戶受管金鑰的許可。該委託人、使用者或角色必須擁有 Amazon Keyspaces 所需客戶受管金鑰的許可。

Amazon Keyspaces 至少需要客戶受管金鑰的下列許可：
+ [kms:Encrypt](https://docs.aws.amazon.com/kms/latest/APIReference/API_Encrypt.html)
+ [kms:Decrypt](https://docs.aws.amazon.com/kms/latest/APIReference/API_Decrypt.html)
+ [kms:ReEncrypt](https://docs.aws.amazon.com/kms/latest/APIReference/API_ReEncrypt.html)\$1 (適用於 kms:ReEncryptFrom and kms:ReEncryptTo)
+ kms:GenerateDataKey\$1 (適用於 [kms:GenerateDataKey](https://docs.aws.amazon.com/kms/latest/APIReference/API_GenerateDataKey.html) 和 [kms:GenerateDataKeyWithoutPlaintext](https://docs.aws.amazon.com/kms/latest/APIReference/API_GenerateDataKeyWithoutPlaintext.html))
+ [kms:DescribeKey](https://docs.aws.amazon.com/kms/latest/APIReference/API_DescribeKey.html)
+ [kms:CreateGrant](https://docs.aws.amazon.com/kms/latest/APIReference/API_CreateGrant.html)

#### 範例金鑰政策
<a name="encryption-customer-managed-policy-sample"></a>

例如，以下範例金鑰政策只會提供必要許可。政策具有下列效果：
+ 允許 Amazon Keyspaces 在密碼編譯操作中使用客戶受管金鑰並建立授予，但僅限於代表帳戶中有權使用 Amazon Keyspaces 的主體時。如果政策陳述式中指定的委託人沒有使用 Amazon Keyspaces 的許可，呼叫會失敗，即使它來自 Amazon Keyspaces 服務。
+ [kms:ViaService](https://docs.aws.amazon.com/kms/latest/developerguide/policy-conditions.html#conditions-kms-via-service) 條件金鑰只有在請求來自 Amazon Keyspaces 時，才允許 許可，這些請求代表政策陳述式中列出的委託人。這些主體無法直接呼叫這些操作。請注意，`kms:ViaService` 值 (`cassandra.*.amazonaws.com`) 在區域位置中有星號 (\$1)。Amazon Keyspaces 需要 許可，才能獨立於任何特定項目 AWS 區域。
+ 授予客戶受管金鑰管理員 （可擔任該`db-team`角色的使用者） 對客戶受管金鑰的唯讀存取權，以及撤銷授予的許可，包括 [Amazon Keyspaces 保護資料表所需的授予](#encryption-grants)。
+ 授予 Amazon Keyspaces 對客戶受管金鑰的唯讀存取權。在這種情況下，Amazon Keyspaces 可以直接呼叫這些操作。它不必代表帳戶委託人採取行動。

使用範例金鑰政策之前，請將範例主體取代為來自您的實際主體 AWS 帳戶。

```
{
  "Id": "key-policy-cassandra",
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Sid" : "Allow access through Amazon Keyspaces for all principals in the account that are authorized to use Amazon Keyspaces",
      "Effect": "Allow",
      "Principal": {"AWS": "arn:aws:iam::111122223333:user/db-lead"},
      "Action": [
        "kms:Encrypt",
        "kms:Decrypt",
        "kms:ReEncrypt*",
        "kms:GenerateDataKey*",
        "kms:DescribeKey",
        "kms:CreateGrant"
      ],
      "Resource": "*",      
      "Condition": { 
         "StringLike": {
           "kms:ViaService" : "cassandra.*.amazonaws.com"
         }
      }
    },
    {
      "Sid":  "Allow administrators to view the customer managed key and revoke grants",
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::111122223333:role/db-team"
       },
      "Action": [
        "kms:Describe*",
        "kms:Get*",
        "kms:List*",
        "kms:RevokeGrant"
      ],
      "Resource": "*"
    }
  ]
}
```

#### 使用授予授權 Amazon Keyspaces
<a name="encryption-grants"></a>

除了金鑰政策之外，Amazon Keyspaces 還使用授予來設定客戶受管金鑰的許可。若要檢視您帳戶中客戶受管金鑰的授予，請使用 [ListGrants](https://docs.aws.amazon.com/kms/latest/APIReference/API_ListGrants.html) 操作。Amazon Keyspaces 不需要授予或任何其他許可，即可使用 [AWS 擁有的金鑰](encryption.howitworks.md#keyspaces-owned)來保護您的資料表。

Amazon Keyspaces 會在執行背景系統維護和持續資料保護任務時使用授予許可。它還使用授與來產生資料表金鑰。

每個授與都專屬於一個資料表。如果帳戶包含以相同客戶受管金鑰加密的多個資料表，則會授予每個資料表的每種類型。[Amazon Keyspaces 加密內容](https://docs.aws.amazon.com/kms/latest/developerguide/encryption-context.html)會限制授予，其中包含資料表名稱和 AWS 帳戶 ID。授予包含不再需要時[淘汰授予的](https://docs.aws.amazon.com/kms/latest/APIReference/API_RetireGrant.html)許可。

若要建立授予，Amazon Keyspaces 必須具有`CreateGrant`代表建立加密資料表的使用者呼叫 的許可。

金鑰政策也會允許帳戶[撤銷客戶受管金鑰上的授予](https://docs.aws.amazon.com/kms/latest/APIReference/API_RevokeGrant.html)。不過，如果您撤銷作用中加密資料表的授予，Amazon Keyspaces 將無法保護和維護資料表。

## 步驟 3：指定新資料表的客戶受管金鑰
<a name="encryption.tutorial-creating"></a>

請依照下列步驟，使用 Amazon Keyspaces 主控台或 CQL 在新資料表上指定客戶受管金鑰。

### 使用客戶受管金鑰建立加密的資料表 （主控台）
<a name="encryption.tutorial-console"></a>

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

1. 在導覽窗格中，選擇 **Tables** (資料表)，然後選擇 **Create table** (建立資料表)。

1. 在**資料表詳細資訊區段的建立**資料表頁面上，選取金鑰空間，並提供新資料表的名稱。 ****

1. 在**結構描述**區段中，建立資料表的結構描述。

1. 在**資料表設定**區段中，選擇**自訂設定**。

1. 繼續至**加密設定**。

   在此步驟中，您會選取資料表的加密設定。

   在**選擇 AWS KMS key**下的**靜態加密**區段中，選擇**選擇不同的 KMS 金鑰 （進階）** 選項，然後在搜尋欄位中，選擇 AWS KMS key 或輸入 Amazon Resource Name (ARN)。
**注意**  
如果您選取的金鑰無法存取或缺少必要的許可，請參閱[《 開發人員指南》中的對金鑰存取進行故障診斷](https://docs.aws.amazon.com/kms/latest/developerguide/policy-evaluation.html)。 AWS Key Management Service 

1. 選擇 **Create** (建立) 以建立加密資料表。

### 使用客戶受管金鑰建立新資料表以進行靜態加密 (CQL)
<a name="encryption.tutorial-cql"></a>

若要建立使用客戶受管金鑰進行靜態加密的新資料表，您可以使用 `CREATE TABLE`陳述式，如下列範例所示。請務必使用授予 Amazon Keyspaces 之許可的有效金鑰的 ARN 取代金鑰 ARN。

```
CREATE TABLE my_keyspace.my_table(id bigint, name text, place text STATIC, PRIMARY KEY(id, name)) WITH CUSTOM_PROPERTIES = {
        'encryption_specification':{
                'encryption_type': 'CUSTOMER_MANAGED_KMS_KEY', 
                'kms_key_identifier':'arn:aws:kms:eu-west-1:5555555555555:key/11111111-1111-111-1111-111111111111'
            }
    };
```

如果您收到 `Invalid Request Exception`，則需要確認客戶受管金鑰有效，且 Amazon Keyspaces 具有必要的許可。若要確認金鑰已正確設定，請參閱《 AWS Key Management Service 開發人員指南》中的對[金鑰存取進行故障診斷](https://docs.aws.amazon.com/kms/latest/developerguide/policy-evaluation.html)。

## 步驟 4：更新現有資料表的加密金鑰
<a name="encryption.tutorial-update"></a>

您也可以使用 Amazon Keyspaces 主控台或 CQL 隨時變更 AWS 擁有的金鑰 和客戶受管 KMS 金鑰之間現有資料表的加密金鑰。

### 使用新的客戶受管金鑰更新現有的資料表 （主控台）
<a name="encryption.tutorial-update-console"></a>

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

1.  在導覽窗格中，選擇 **Tables** (資料表)。

1. 選擇您要更新的資料表，然後選擇**其他設定**索引標籤。

1. 在**靜態加密**區段中，選擇**管理加密**以編輯資料表的加密設定。

   在**選擇 AWS KMS key**下，選擇選項 **選擇不同的 KMS 金鑰 （進階）**，然後在搜尋欄位中選擇 AWS KMS key 或輸入 Amazon Resource Name (ARN)。
**注意**  
如果您選取的金鑰無效，請參閱《 AWS Key Management Service 開發人員指南》中的[對金鑰存取進行故障診斷](https://docs.aws.amazon.com/kms/latest/developerguide/policy-evaluation.html)。

   或者，您可以 AWS 擁有的金鑰 為使用客戶受管金鑰加密的資料表選擇 。

1. 選擇**儲存變更**以儲存您對資料表的變更。

### 更新用於現有資料表的加密金鑰
<a name="encryption.tutorial-update-cql"></a>

若要變更現有資料表的加密金鑰，您可以使用 `ALTER TABLE`陳述式來指定用於靜態加密的客戶受管金鑰。請務必使用授予 Amazon Keyspaces 之許可的有效金鑰的 ARN 取代金鑰 ARN。

```
ALTER TABLE my_keyspace.my_table WITH CUSTOM_PROPERTIES = {     
              'encryption_specification':{ 
                      'encryption_type': 'CUSTOMER_MANAGED_KMS_KEY', 
                      'kms_key_identifier':'arn:aws:kms:eu-west-1:5555555555555:key/11111111-1111-111-1111-111111111111'     
                  } 
         };
```

如果您收到 `Invalid Request Exception`，則需要確認客戶受管金鑰有效，且 Amazon Keyspaces 具有必要的許可。若要確認金鑰已正確設定，請參閱《 AWS Key Management Service 開發人員指南》中的對[金鑰存取進行故障診斷](https://docs.aws.amazon.com/kms/latest/developerguide/policy-evaluation.html)。

若要使用 將加密金鑰變更回預設靜態加密選項 AWS 擁有的金鑰，您可以使用 `ALTER TABLE`陳述式，如下列範例所示。

```
ALTER TABLE my_keyspace.my_table WITH CUSTOM_PROPERTIES = {
                'encryption_specification':{
                      'encryption_type' : 'AWS_OWNED_KMS_KEY' 
                    } 
         };
```

## 步驟 5：在日誌中使用 Amazon Keyspaces 加密內容
<a name="encryption-context"></a>

[加密內容](https://docs.aws.amazon.com/kms/latest/developerguide/encrypt_context.html)是一組金鑰/值對，其中包含任意非私密資料。當您在加密資料的請求中包含加密內容時， 會以 AWS KMS 加密方式將加密內容繫結至加密的資料。若要解密資料，您必須傳遞相同的加密內容。

Amazon Keyspaces 在所有 AWS KMS 密碼編譯操作中使用相同的加密內容。如果您使用[客戶受管金鑰](encryption.howitworks.md#customer-managed)來保護 Amazon Keyspaces 資料表，您可以使用加密內容來識別稽核記錄和日誌中客戶受管金鑰的使用。它也會以純文字顯示在日誌中，例如 [AWS CloudTrail](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-user-guide.html)和 [Amazon CloudWatch Logs ](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/WhatIsCloudWatchLogs.html)的日誌中。

在對 的請求中 AWS KMS，Amazon Keyspaces 使用具有三個鍵/值對的加密內容。

```
"encryptionContextSubset": {
    "aws:cassandra:keyspaceName": "my_keyspace",
    "aws:cassandra:tableName": "mytable"
    "aws:cassandra:subscriberId": "111122223333"
}
```
+ **金鑰空間** – 第一個金鑰/值對會識別包含 Amazon Keyspaces 正在加密之資料表的金鑰空間。金鑰為 `aws:cassandra:keyspaceName`。值是金鑰空間的名稱。

  ```
  "aws:cassandra:keyspaceName": "<keyspace-name>"
  ```

  例如：

  ```
  "aws:cassandra:keyspaceName": "my_keyspace"
  ```
+ **資料表** – 第二個金鑰/值對可識別 Amazon Keyspaces 正在加密的資料表。金鑰為 `aws:cassandra:tableName`。值是資料表的名稱。

  ```
  "aws:cassandra:tableName": "<table-name>"
  ```

  例如：

  ```
  "aws:cassandra:tableName": "my_table"
  ```
+ **帳戶** – 第三個鍵/值對識別 AWS 帳戶。金鑰為 `aws:cassandra:subscriberId`。值是帳戶 ID。

  ```
  "aws:cassandra:subscriberId": "<account-id>"
  ```

  例如：

  ```
  "aws:cassandra:subscriberId": "111122223333"
  ```

## 步驟 6：使用 設定監控 AWS CloudTrail
<a name="encryption-cmk-trail"></a>

如果您使用[客戶受管金鑰](encryption.howitworks.md#customer-managed)來保護 Amazon Keyspaces 資料表，您可以使用 AWS CloudTrail 日誌來追蹤 Amazon Keyspaces AWS KMS 代表您傳送給 的請求。

本節會討論 `GenerateDataKey`、`Decrypt`、 `DescribeKey`和 `CreateGrant`請求。此外，Amazon Keyspaces 會使用 [RetireGrant](https://docs.aws.amazon.com/kms/latest/APIReference/API_RetireGrant.html) 操作，在刪除資料表時移除授予。

**注意**  
當您使用 Amazon Keyspaces 時，某些操作可能會產生具有 `invokedBy` 欄位的 CloudTrail 事件`dynamodb.amazonaws.com`。這是預期會發生的，因為 Amazon Keyspaces 與 Amazon DynamoDB 整合以提供其服務。

**GenerateDataKey**  
Amazon Keyspaces 會建立唯一的資料表金鑰來加密靜態資料。它會將 *[GenerateDataKey](https://docs.aws.amazon.com/kms/latest/APIReference/API_GenerateDataKey.html)* 請求傳送至 AWS KMS ，以指定資料表的 KMS 金鑰。  
記錄 `GenerateDataKey` 操作的事件類似於以下範例事件。使用者是 Amazon Keyspaces 服務帳戶。這些參數包括客戶受管金鑰的 Amazon Resource Name (ARN)、需要 256 位元金鑰的金鑰指標，以及識別金鑰空間、資料表和 的[加密內容](#encryption-context) AWS 帳戶。  

```
{
    "eventVersion": "1.08",
    "userIdentity": {
        "type": "AWSService",
        "invokedBy": "AWS Internal"
    },
    "eventTime": "2021-04-16T04:56:05Z",
    "eventSource": "kms.amazonaws.com",
    "eventName": "GenerateDataKey",
    "awsRegion": "us-east-1",
    "sourceIPAddress": "AWS Internal",
    "userAgent": "AWS Internal",
    "requestParameters": {
        "keySpec": "AES_256",
        "encryptionContext": {
            "aws:cassandra:keyspaceName": "my_keyspace",
            "aws:cassandra:tableName": "my_table",
            "aws:cassandra:subscriberId": "123SAMPLE012"
        },
        "keyId": "arn:aws:kms:eu-west-1:5555555555555:key/11111111-1111-111-1111-111111111111"
    },
    "responseElements": null,
    "requestID": "5e8e9cb5-9194-4334-aacc-9dd7d50fe246",
    "eventID": "49fccab9-2448-4b97-a89d-7d5c39318d6f",
    "readOnly": true,
    "resources": [
        {
            "accountId": "123SAMPLE012",
            "type": "AWS::KMS::Key",
            "ARN": "arn:aws:kms:eu-west-1:5555555555555:key/11111111-1111-111-1111-111111111111"
        }
    ],
    "eventType": "AwsApiCall",
    "managementEvent": true,
    "eventCategory": "Management",
    "recipientAccountId": "123SAMPLE012",
    "sharedEventID": "84fbaaf0-9641-4e32-9147-57d2cb08792e"
}
```

**DescribeKey**  
Amazon Keyspaces 使用 [DescribeKey](https://docs.aws.amazon.com/kms/latest/APIReference/API_DescribeKey.html) 操作來判斷您選取的 KMS 金鑰是否存在於帳戶和區域中。  
記錄 `DescribeKey` 操作的事件類似於以下範例事件。使用者是 Amazon Keyspaces 服務帳戶。這些參數包括客戶受管金鑰的 ARN，以及需要 256 位元金鑰的金鑰指標。  

```
{
    "eventVersion": "1.08",
    "userIdentity": {
        "type": "IAMUser",
        "principalId": "AIDAZ3FNIIVIZZ6H7CFQG",
        "arn": "arn:aws:iam::123SAMPLE012:user/admin",
        "accountId": "123SAMPLE012",
        "accessKeyId": "AKIAIOSFODNN7EXAMPLE",
        "userName": "admin",
        "sessionContext": {
            "sessionIssuer": {},
            "webIdFederationData": {},
            "attributes": {
                "mfaAuthenticated": "false",
                "creationDate": "2021-04-16T04:55:42Z"
            }
        },
        "invokedBy": "AWS Internal"
    },
    "eventTime": "2021-04-16T04:55:58Z",
    "eventSource": "kms.amazonaws.com",
    "eventName": "DescribeKey",
    "awsRegion": "us-east-1",
    "sourceIPAddress": "AWS Internal",
    "userAgent": "AWS Internal",
    "requestParameters": {
        "keyId": "arn:aws:kms:eu-west-1:5555555555555:key/11111111-1111-111-1111-111111111111"
    },
    "responseElements": null,
    "requestID": "c25a8105-050b-4f52-8358-6e872fb03a6c",
    "eventID": "0d96420e-707e-41b9-9118-56585a669658",
    "readOnly": true,
    "resources": [
        {
            "accountId": "123SAMPLE012",
            "type": "AWS::KMS::Key",
            "ARN": "arn:aws:kms:eu-west-1:5555555555555:key/11111111-1111-111-1111-111111111111"
        }
    ],
    "eventType": "AwsApiCall",
    "managementEvent": true,
    "eventCategory": "Management",
    "recipientAccountId": "123SAMPLE012"
}
```

**解密**  
當您存取 Amazon Keyspaces 資料表時，Amazon Keyspaces 需要解密資料表金鑰，以便在階層中解密其下方的金鑰。然後解密資料表中的資料。若要解密資料表金鑰，Amazon Keyspaces 會將[解密](https://docs.aws.amazon.com/kms/latest/APIReference/API_Decrypt.html)請求傳送至 AWS KMS ，以指定資料表的 KMS 金鑰。  
記錄 `Decrypt` 操作的事件類似於以下範例事件。使用者是 中存取資料表 AWS 帳戶 的主體。這些參數包括加密的資料表金鑰 （做為加密文字 Blob)，以及識別資料表和 的[加密內容](#encryption-context) AWS 帳戶。 會從加密文字 AWS KMS 衍生客戶受管金鑰的 ID。  

```
{
    "eventVersion": "1.08",
    "userIdentity": {
        "type": "AWSService",
        "invokedBy": "AWS Internal"
    },
    "eventTime": "2021-04-16T05:29:44Z",
    "eventSource": "kms.amazonaws.com",
    "eventName": "Decrypt",
    "awsRegion": "us-east-1",
    "sourceIPAddress": "AWS Internal",
    "userAgent": "AWS Internal",
    "requestParameters": {
        "encryptionContext": {
            "aws:cassandra:keyspaceName": "my_keyspace",
            "aws:cassandra:tableName": "my_table",
            "aws:cassandra:subscriberId": "123SAMPLE012"
        },
        "encryptionAlgorithm": "SYMMETRIC_DEFAULT"
    },
    "responseElements": null,
    "requestID": "50e80373-83c9-4034-8226-5439e1c9b259",
    "eventID": "8db9788f-04a5-4ae2-90c9-15c79c411b6b",
    "readOnly": true,
    "resources": [
        {
            "accountId": "123SAMPLE012",
            "type": "AWS::KMS::Key",
            "ARN": "arn:aws:kms:eu-west-1:5555555555555:key/11111111-1111-111-1111-111111111111"
        }
    ],
    "eventType": "AwsApiCall",
    "managementEvent": true,
    "eventCategory": "Management",
    "recipientAccountId": "123SAMPLE012",
    "sharedEventID": "7ed99e2d-910a-4708-a4e3-0180d8dbb68e"
}
```

**CreateGrant**  
當您使用[客戶受管金鑰](encryption.howitworks.md#customer-managed)來保護 Amazon Keyspaces 資料表時，Amazon Keyspaces 會使用[授予](#encryption-grants)來允許服務執行持續的資料保護和維護和耐久性任務。在 上不需要這些授權[AWS 擁有的金鑰](encryption.howitworks.md#keyspaces-owned)。  
Amazon Keyspaces 建立的授予專屬於資料表。[CreateGrant](https://docs.aws.amazon.com/kms/latest/APIReference/API_CreateGrant.html) 請求中的主體是建立資料表的使用者。  
記錄 `CreateGrant` 操作的事件類似於以下範例事件。這些參數包括資料表的客戶受管金鑰 ARN、承授者委託人和淘汰委託人 (Amazon Keyspaces 服務），以及授予涵蓋的操作。它還包含需要所有加密操作使用指定[加密內容](#encryption-context)的限制。  

```
{
    "eventVersion": "1.08",
    "userIdentity": {
        "type": "IAMUser",
        "principalId": "AIDAZ3FNIIVIZZ6H7CFQG",
        "arn": "arn:aws:iam::arn:aws:kms:eu-west-1:5555555555555:key/11111111-1111-111-1111-111111111111:user/admin",
        "accountId": "arn:aws:kms:eu-west-1:5555555555555:key/11111111-1111-111-1111-111111111111",
        "accessKeyId": "AKIAI44QH8DHBEXAMPLE",
        "userName": "admin",
        "sessionContext": {
            "sessionIssuer": {},
            "webIdFederationData": {},
            "attributes": {
                "mfaAuthenticated": "false",
                "creationDate": "2021-04-16T04:55:42Z"
            }
        },
        "invokedBy": "AWS Internal"
    },
    "eventTime": "2021-04-16T05:11:10Z",
    "eventSource": "kms.amazonaws.com",
    "eventName": "CreateGrant",
    "awsRegion": "us-east-1",
    "sourceIPAddress": "AWS Internal",
    "userAgent": "AWS Internal",
    "requestParameters": {
        "keyId": "a7d328af-215e-4661-9a69-88c858909f20",
        "operations": [
            "DescribeKey",
            "GenerateDataKey",
            "Decrypt",
            "Encrypt",
            "ReEncryptFrom",
            "ReEncryptTo",
            "RetireGrant"
        ],
        "constraints": {
            "encryptionContextSubset": {
                "aws:cassandra:keyspaceName": "my_keyspace",
                "aws:cassandra:tableName": "my_table",
                "aws:cassandra:subscriberId": "123SAMPLE012"
            }
        },
        "retiringPrincipal": "cassandratest.us-east-1.amazonaws.com",
        "granteePrincipal": "cassandratest.us-east-1.amazonaws.com"
    },
    "responseElements": {
        "grantId": "18e4235f1b07f289762a31a1886cb5efd225f069280d4f76cd83b9b9b5501013"
    },
    "requestID": "b379a767-1f9b-48c3-b731-fb23e865e7f7",
    "eventID": "29ee1fd4-28f2-416f-a419-551910d20291",
    "readOnly": false,
    "resources": [
        {
            "accountId": "123SAMPLE012",
            "type": "AWS::KMS::Key",
            "ARN": "arn:aws:kms:eu-west-1:5555555555555:key/11111111-1111-111-1111-111111111111"
        }
    ],
    "eventType": "AwsApiCall",
    "managementEvent": true,
    "eventCategory": "Management",
    "recipientAccountId": "123SAMPLE012"
}
```