

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

# 在 Amazon Verified Permissions 中加密資源
<a name="security-data-protection-cmk"></a>

Amazon Verified Permissions 預設提供加密，以使用 AWS 擁有的加密金鑰保護靜態敏感客戶資料。Amazon Verified Permissions 可讓您使用 AWS Key Management Service (AWS KMS) 客戶受管金鑰 s (CMK) 加密政策存放區，這是多一層保護。此功能可確保透過靜態加密保護敏感資料，這可協助您：
+ 減輕應用程式端的操作負擔，以保護敏感資料
+ 持續控制誰可以透過您自己的 AWS KMS 客戶受管金鑰來查看授權政策的詳細資訊
+ 建立對安全性要求甚高的應用程式，以符合嚴格的加密合規或管制需求。

下列各節說明如何設定新政策存放區的加密和管理加密金鑰。

## AWS KMS Amazon Verified Permissions 的金鑰類型
<a name="kms-key-types"></a>

Amazon Verified Permissions 與 整合 AWS KMS ，以管理用於加密/解密客戶資料的加密金鑰。若要進一步瞭解金鑰類型和狀態，請參閱 *AWS KMS 開發人員指南*中的[AWS Key Management Service 概念](https://docs.aws.amazon.com/kms/latest/developerguide/concepts-intro.html)。當您建立新的政策存放區時，您可以選擇下列 AWS KMS 金鑰類型來加密您的資料：

### AWS 擁有的金鑰
<a name="aws-owned-key"></a>

預設加密類型。Amazon Verified Permissions 會免費擁有金鑰，並在建立時加密靜態資源資料。您的程式碼或應用程式中不需要額外的組態，即可使用 Verified Permissions 擁有的金鑰來加密/解密您的資料。

### 客戶受管金鑰
<a name="customer-managed-key"></a>

您可以在 AWS 帳戶中建立、擁有和管理金鑰。您可以完全控制 AWS KMS key. AWS KMS charges 適用於 客戶受管金鑰。如需詳細資訊，請參閱 [AWS KMS 定價](https://aws.amazon.com/kms/pricing/)頁面。如需金鑰類型的詳細資訊，請參閱《 *AWS KMS 開發人員指南*》中的[客戶受管金鑰](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#customer-mgn-key)。

當您為頂層資源 （即政策存放區） 指定 客戶受管金鑰 加密的 時，Verified Permissions 會使用該金鑰加密資源及其子資源。若要使用 加密政策存放區 客戶受管金鑰，您需要在金鑰政策中授予對已驗證許可的存取權。金鑰政策是您連接到 以 客戶受管金鑰 控制其存取[的資源型政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html#policies_resource-based)。如需詳細資訊，請參閱[授權將您的 AWS KMS 金鑰用於 Amazon Verified Permissions](#authorizing-kms-key-use)。

此外，若要使用 建立加密的政策存放區 客戶受管金鑰，或對由 加密的政策存放區進行 API 呼叫 客戶受管金鑰，進行呼叫的 IAM 使用者或角色也必須具有 金鑰的存取權。如果 Verified Permissions 無法存取金鑰，任何涉及該金鑰加密資源的授權決策都可能過時或不準確。當您無法存取金鑰時，您將無法read/update/delete該金鑰加密的資源，而且任何使用金鑰進行加密的建立呼叫都會失敗。

**注意**  
Verified Permissions 靜態加密可在有 Verified Permissions 的所有 AWS 區域中使用。

**重要**  
一旦 客戶受管金鑰 使用 加密政策存放區，您就無法更新資源以使用不同的金鑰進行加密，或從該政策存放區移除金鑰。

## 搭配 Amazon Verified Permissions 使用 AWS KMS 和 資料金鑰
<a name="using-kms-data-keys"></a>

Amazon Verified Permissions 靜態加密功能使用 AWS KMS 金鑰和資料金鑰階層來保護您的資源資料。

**注意**  
Amazon Verified Permissions 僅支援對稱 AWS KMS 金鑰。您無法使用非對稱 AWS KMS 金鑰來加密 Amazon Verified Permissions 資源。

### 使用 AWS 擁有的金鑰
<a name="using-aws-owned-keys"></a>

Amazon Verified Permissions 預設會使用 AWS 擁有的金鑰加密所有資源。這些金鑰可免費使用，並會每年輪換，以保護您的帳戶資源。您不需要檢視、管理、使用或稽核這些金鑰，因此不需採取任何動作進行資料保護。如需 AWS 擁有金鑰的詳細資訊，請參閱《 *AWS KMS 開發人員指南*》中的 [AWS 擁有金鑰](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#aws-owned-key)。

### 使用客戶受管金鑰
<a name="using-customer-managed-keys"></a>

選取 客戶受管金鑰 用於加密的 可提供下列優點：
+ 您可以建立和管理 AWS KMS 金鑰，包括設定金鑰政策和 IAM 政策來控制 AWS KMS 對金鑰的存取。您可以啟用和停用 AWS KMS 金鑰、啟用和停用自動金鑰輪換，並在金鑰不再使用 AWS KMS 時將其刪除。
+ 您可以在您擁有和管理的自訂金鑰存放區 客戶受管金鑰 中使用 客戶受管金鑰 具有匯入金鑰材料的 或 。
+ 您可以在 AWS CloudTrail 日誌 AWS KMS 中檢查對 的 Amazon Verified Permissions API 呼叫，以稽核 Verified Permissions 資源的加密和解密。

若要讓 Amazon Verified Permissions 客戶受管金鑰使用您的 進行加密/解密，您需要新增特定金鑰政策，以允許 Amazon Verified Permissions 代表您加密/解密資源。

## 授權將您的 AWS KMS 金鑰用於 Amazon Verified Permissions
<a name="authorizing-kms-key-use"></a>

Amazon Verified Permissions 至少需要下列 許可 客戶受管金鑰：
+ `kms:Encrypt`
+ `kms:GenerateDataKeyWithoutPlaintext`
+ `kms:DescribeKey`
+ `kms:ReEncryptTo`
+ `kms:ReEncryptFrom`
+ `kms:Decrypt`

範例金鑰政策如下所示：

```
{  
    "Sid": "Enable AVP to use the KMS key for encrypting project J.A.K. policy resources",
    "Effect": "Allow",  
    "Principal": {  
        "Service": "verifiedpermissions.amazonaws.com"  
    },  
    "Action": [  
        "kms:Decrypt",  
        "kms:GenerateDataKeyWithoutPlaintext",  
        "kms:Encrypt",  
        "kms:ReEncryptFrom",  
        "kms:ReEncryptTo",  
        "kms:DescribeKey"  
    ],  
    "Resource": "*"  
}
```

### 了解來源內容
<a name="understanding-source-context"></a>

來源內容提供來源發起人嘗試對指定金鑰執行 AWS KMS 動作的相關資訊。這可透過將內容繫結至資料來源，來防止加密資料的混淆或濫用。

客戶可以利用來源內容作為其金鑰政策的其他條件，例如下列金鑰政策陳述式：

```
{  
    "Version": "2012-10-17", 		 	 	 
    "Statement": [  
        {  
            "Sid": "Enable this account full access to this key",  
            "Effect": "Allow",  
            "Principal": {  
                "AWS": "arn:aws:iam::111122223333:root"  
            },  
            "Action": "kms:*",  
            "Resource": "*"  
        },  
        {  
            "Sid": "Enable AVP to retrieve this key's metadata",  
            "Effect": "Allow",  
            "Principal": {  
                "Service": "verifiedpermissions.amazonaws.com"  
            },  
            "Action": "kms:DescribeKey",  
            "Resource": "*",  
            "Condition": {  
                "StringEquals": {  
                    "aws:SourceAccount": "111122223333"  
                },  
                "StringLike": {  
                    "aws:SourceArn": "arn:aws:verifiedpermissions::111122223333:policy-store/*"  
                }  
            }  
        },  
        {  
            "Sid": "Enable AVP to encrypt/decrypt resources utilizing this key",  
            "Effect": "Allow",  
            "Principal": {  
                "Service": "verifiedpermissions.amazonaws.com"  
            },  
            "Action": [  
                "kms:Decrypt",  
                "kms:ReEncryptTo",  
                "kms:ReEncryptFrom",  
                "kms:GenerateDataKeyWithoutPlaintext",  
                "kms:Encrypt"  
            ],  
            "Resource": "*",  
            "Condition": {  
                "StringEquals": {  
                    "aws:SourceAccount": "111122223333"  
                },  
                "StringLike": {  
                    "aws:SourceArn": "arn:aws:verifiedpermissions::111122223333:policy-store/*"  
                }  
            }  
        }  
    ]  
}
```

如果來源帳戶與此 AWS KMS 金鑰所在的帳戶相同，則此金鑰政策允許 Verified Permissions 代表您進行 AWS KMS 呼叫。檢查 CMK 金鑰的 AWS CloudTrail 稽核日誌時，這些值應可驗證。如需全域 AWS 條件索引鍵的詳細資訊，請參閱[使用 `aws:SourceArn`或 `aws:SourceAccount` 條件索引鍵](https://docs.aws.amazon.com/kms/latest/developerguide/least-privilege.html#key-policy-least-privilege)。

### 了解加密內容
<a name="understanding-encryption-context"></a>

加密內容是一組金鑰值對，其中包含用於加密完整性檢查的其他已驗證資料。當您在加密資料的請求中包含加密內容時， 會以 AWS KMS 加密方式將加密內容繫結至加密的資料。若要解密資料，您必須傳遞相同的加密內容。

Amazon Verified Permissions 在所有 AWS KMS 密碼編譯操作中使用相同的加密內容，而且可以在 Verified Permissions 代表您進行加密/解密程序 AWS KMS 呼叫時，在日誌中 AWS CloudTrail 驗證。根據預設，Verified Permissions 在加密您的資源時會使用下列加密內容金鑰/值對：

```
{  
    "aws:verifiedpermissions:policy-store-arn": "arn:aws:verifiedpermissions::111122223333:policy-store/PSt123456789012"  
}
```

Amazon Verified Permissions 也可讓您附加自訂加密內容，做為您希望在加密/解密程序期間包含的其他中繼資料的一部分。這表示您的金鑰政策在授予許可時可以更精細，例如以下範例：

```
{  
    "Version": "2012-10-17", 		 	 	 
    "Statement": [  
        {  
            "Sid": "Enable this account full access to this key",  
            "Effect": "Allow",  
            "Principal": {  
                "AWS": "arn:aws:iam::111122223333:root"  
            },  
            "Action": "kms:*",  
            "Resource": "*"  
        },  
        {  
            "Sid": "Enable AVP to retrieve this key's metadata",  
            "Effect": "Allow",  
            "Principal": {  
                "Service": "verifiedpermissions.amazonaws.com"  
            },  
            "Action": "kms:DescribeKey",  
            "Resource": "*"  
        },  
        {  
            "Sid": "Enable AVP to encrypt/decrypt resources utilizing this key",  
            "Effect": "Allow",  
            "Principal": {  
                "Service": "verifiedpermissions.amazonaws.com"  
            },  
            "Action": [  
                "kms:Decrypt",  
                "kms:ReEncryptTo",  
                "kms:ReEncryptFrom",  
                "kms:GenerateDataKeyWithoutPlaintext",  
                "kms:Encrypt"  
            ],  
            "Resource": "*",  
            "Condition": {  
                "StringLike": {  
                    "kms:EncryptionContext:aws:verifiedpermissions:policy-store-arn": "arn:aws:verifiedpermissions::111122223333:policy-store/*",  
                    "kms:EncryptionContext:policy_owner": "Tim"  
                }  
            }  
        }  
    ]  
}
```

如果加密內容映射包含金鑰 ，其值遵循 格式，`arn:aws:verifiedpermissions::111122223333:policy-store/*`且也包含金鑰值對 `aws:verifiedpermissions:policy-store-arn`，則此金鑰政策允許 Verified Permissions 代表您進行 AWS KMS 呼叫`"policy_owner": "Tim"`。如需如何設定自訂加密內容[建立加密政策存放區](#creating-encrypted-policy-store)，請參閱 。

**注意**  
對於條件根據加密內容的金鑰政策，建議使用加密內容映射的子集，而不是檢查每個金鑰值對。上游的服務及其相依性可能會新增您看不到的其他金鑰值對，如果金鑰政策根據加密內容映射的**確切**外觀有條件地允許 ，則可能會影響 Verified Permissions 的金鑰存取。

### 了解 kms:ViaService
<a name="understanding-kms-viaservice"></a>

`kms:ViaService` 條件金鑰會將 AWS KMS 金鑰的使用限制為來自指定 AWS 服務的請求。此條件金鑰僅適用於[轉送存取工作階段](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_forward_access_sessions.html) (FAS)。如需 的詳細資訊`kms:ViaService`，請參閱《 *AWS KMS 開發人員指南*》中的 [kms:ViaService](https://docs.aws.amazon.com/kms/latest/developerguide/conditions-kms.html#conditions-kms-via-service)。

例如，下列金鑰政策陳述式使用 `kms:ViaService`條件金鑰，允許 僅在請求來自美國東部 （維吉尼亞北部） 區域的 Amazon Verified Permissions 時[客戶受管金鑰](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#customer-mgn-key)，才用於指定的動作`BrentRole`。

```
{  
    "Sid": "Enable AVP to encrypt/decrypt resources using credentials of BrentRole",  
    "Effect": "Allow",  
    "Principal": {  
        "AWS": "arn:aws:iam::111122223333:role/BrentRole"  
    },  
    "Action": [  
        "kms:Decrypt",  
        "kms:GenerateDataKeyWithoutPlaintext",  
        "kms:Encrypt",  
        "kms:ReEncryptFrom",  
        "kms:ReEncryptTo",  
        "kms:DescribeKey"  
    ],  
    "Resource": "*",  
    "Condition": {  
        "StringEquals": {  
            "kms:ViaService": [  
                "verifiedpermissions.us-east-1.amazonaws.com"  
            ]  
        }  
    }  
}
```

這是 Verified Permissions AWS KMS 代表您向 提出加密/解密請求時，Verified Permissions 能夠傳遞您的身分、許可和工作階段屬性的必要條件。如需 FAS 請求的詳細資訊，請參閱*IAM 《 使用者指南*》中的[轉送存取工作階段](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_forward_access_sessions.html)。

### 完成 AWS KMS 金鑰政策
<a name="complete-kms-key-policy"></a>

根據先前章節中的概念，這是允許 Amazon Verified Permissions 使用 CMK 進行加密/解密的範例金鑰政策：

```
{  
    "Version": "2012-10-17", 		 	 	 
    "Statement": [  
        {  
            "Sid": "Enable this account full access to this key",  
            "Effect": "Allow",  
            "Principal": {  
                "AWS": "arn:aws:iam::111122223333:root"  
            },  
            "Action": "kms:*",  
            "Resource": "*"  
        },  
        {  
            "Sid": "Enable AVP to retrieve this key's metadata",  
            "Effect": "Allow",  
            "Principal": {  
                "Service": "verifiedpermissions.amazonaws.com"  
            },  
            "Action": "kms:DescribeKey",  
            "Resource": "*",  
            "Condition": {  
                "StringEquals": {  
                    "aws:SourceAccount": "111122223333"  
                },  
                "StringLike": {  
                    "aws:SourceArn": "arn:aws:verifiedpermissions::111122223333:policy-store/*"  
                }  
            }  
        },  
        {  
            "Sid": "Enable AVP to encrypt/decrypt resources utilizing this key",  
            "Effect": "Allow",  
            "Principal": {  
                "Service": "verifiedpermissions.amazonaws.com"  
            },  
            "Action": [  
                "kms:Decrypt",  
                "kms:ReEncryptTo",  
                "kms:ReEncryptFrom",  
                "kms:Encrypt",  
                "kms:GenerateDataKeyWithoutPlaintext"  
            ],  
            "Resource": "*",  
            "Condition": {  
                "StringLike": {  
                    "kms:EncryptionContext:aws:verifiedpermissions:policy-store-arn": "arn:aws:verifiedpermissions::111122223333:policy-store/*",  
                    "kms:EncryptionContext:policy_owner": "Tim",  
                    "aws:SourceArn": "arn:aws:verifiedpermissions::111122223333:policy-store/*"  
                },  
                "StringEquals": {  
                    "aws:SourceAccount": "111122223333"  
                }  
            }  
        },  
        {  
            "Sid": "Enable AVP to encrypt/decrypt resources using credentials of BrentRole",  
            "Effect": "Allow",  
            "Principal": {  
                "AWS": "arn:aws:iam::111122223333:role/BrentRole"  
            },  
            "Action": [  
                "kms:Decrypt",  
                "kms:GenerateDataKeyWithoutPlaintext",  
                "kms:Encrypt",  
                "kms:ReEncryptFrom",  
                "kms:ReEncryptTo",  
                "kms:DescribeKey"  
            ],  
            "Resource": "*",  
            "Condition": {  
                "StringEquals": {  
                    "kms:ViaService": [  
                        "verifiedpermissions.us-east-1.amazonaws.com"  
                    ]  
                },  
                "StringLike": {  
                    "kms:EncryptionContext:aws:verifiedpermissions:policy-store-arn": "arn:aws:verifiedpermissions::111122223333:policy-store/*",  
                    "kms:EncryptionContext:policy_owner": "Tim"  
                }  
            }  
        }  
    ]  
}
```

**警告**  
修改 Amazon Verified Permissions 已使用 AWS KMS 之金鑰的金鑰政策時請小心。雖然 Verified Permissions 會在您最初在建立頂層資源期間設定 AWS KMS 金鑰時驗證加密和解密許可，但無法驗證後續政策隨需變更。不小心移除必要的許可可能會中斷您的授權決策和定期驗證許可服務流程。如需疑難排解 Amazon Verified Permissions 中與 客戶受管金鑰相關的常見錯誤的指引，請參閱 [對 Amazon Verified Permissions 中的客戶受管金鑰進行故障診斷](#troubleshoot-cmk)。

### 加密資源的必要 IAM 政策
<a name="iam-policy-for-encrypted-resources"></a>

透過帳戶中 IAM 的角色呼叫 Verified Permissions 的客戶，將需要確保對應的 IAM 政策具有適當的許可，以利用 客戶受管金鑰 進行資源的加密和解密。

若要建立由 加密的政策存放區 客戶受管金鑰，下列 IAM 政策會說明執行此操作所需的最低限度 AWS KMS 和已驗證許可動作：

```
{
    "Version": "2012-10-17", 		 	 	 
    "Statement": [
        {
            "Action": "verifiedpermissions:CreatePolicyStore",
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "kms:Decrypt",
                "kms:Encrypt",
                "kms:ReEncryptTo",
                "kms:ReEncryptFrom",
                "kms:DescribeKey",
                "kms:GenerateDataKeyWithoutPlaintext"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}
```

**注意**  
對於擷取 （取得\$1 和清單\$1 操作） 和刪除由 加密的政策存放區 客戶受管金鑰，不需要額外的許可。

若要更新由 加密的政策存放區 客戶受管金鑰、擷取 （取得\$1 和清單\$1 操作）、更新和刪除由 加密之政策存放區的子資源 客戶受管金鑰，下列 IAM 政策會說明最低限度的必要 AWS KMS 和驗證許可動作：

```
{
    "Version": "2012-10-17", 		 	 	 
    "Statement": [
        {
            "Action": "verifiedpermissions:*",
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "kms:Decrypt"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}
```

做為單一 IAM 政策，客戶只需將下列項目新增至其 IAM 角色政策：

```
{
    "Version": "2012-10-17", 		 	 	 
    "Statement": [
        {
            "Action": "verifiedpermissions:*",
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "kms:Decrypt",
                "kms:Encrypt",
                "kms:ReEncryptTo",
                "kms:ReEncryptFrom",
                "kms:DescribeKey",
                "kms:GenerateDataKeyWithoutPlaintext"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}
```

## 管理加密政策存放區
<a name="managing-encrypted-policy-stores"></a>

政策存放區是包含所有相關政策資源的入門層級容器。如需政策存放區和子資源階層的詳細資訊，請參閱《[Amazon Verified Permissions 使用者指南》中的 Amazon Verified Permissions 政策存放](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/policy-stores.html)區。 **

在 Verified Permissions 中建立政策存放區時，您可以使用 AWS KMS 金鑰啟用靜態加密。這可確保：
+ 政策存放區及其子資源上的所有讀取、更新和刪除操作都會使用提供的 客戶受管金鑰 進行解密程序
+ 任何授權決策呼叫 （即 IsAuthorized、BatchIsAuthorized、IsAuthorizedWithToken 等） 將使用提供的 客戶受管金鑰 進行解密程序

### 建立加密政策存放區
<a name="creating-encrypted-policy-store"></a>

建立加密政策存放區之前，請確定 客戶受管金鑰 您使用的 已設定適當的金鑰政策陳述式，以便 Amazon Verified Permissions 將金鑰用於加密/解密。如需必要許可[授權將您的 AWS KMS 金鑰用於 Amazon Verified Permissions](#authorizing-kms-key-use)，請參閱 。

使用 AWS CLI：

```
aws verifiedpermissions create-policy-store --region us-east-1 --encryption-settings file://encrypted.json --validation-settings "{\"mode\": \"OFF\"}"
```

其中`encrypted.json`看起來像：

```
{  
    "kmsEncryptionSettings": {  
        "key": "arn:aws:kms:us-east-1:111122223333:key/12345678-90ab-cdef-ghij-klmnopqrstuv",  
        "encryptionContext": {  
            "<ENCRYPTION_CONTEXT_KEY_1>": "<ENCRYPTION_CONTEXT_VALUE_1>",  
            "<ENCRYPTION_CONTEXT_KEY_2>": "<ENCRYPTION_CONTEXT_VALUE_2>",  
            ...  
        }  
    }  
}
```

請務必將 取代`key`為您的 客戶受管金鑰 ARN，並將 `<ENCRYPTION_CONTEXT_KEY>`和 `<ENCRYPTION_CONTEXT_VALUE>`取代為所需的`encryptionContext`鍵值對。如果不需要新增鍵值對， `encryptionContext` 可以完全省略。

**重要**  
請勿在自訂加密內容`aws:verifiedpermissions:policy-store-arn`中包含金鑰/值對。這會自動新增，如果它是您傳遞的自訂加密內容金鑰/值對的一部分，則會導致驗證錯誤。

如需政策存放區子資源可用 APIs 的詳細資訊，請參閱《*Amazon Verified Permissions API 參考指南*》中的[動作](https://docs.aws.amazon.com/verifiedpermissions/latest/apireference/API_Operations.html)。

**注意**  
如果 Amazon Verified Permissions 資源 AWS KMS 客戶受管金鑰 使用的 因不正確的 AWS KMS 金鑰政策而遭到刪除、停用或無法存取，資源解密將會失敗，進而導致授權決策過時。視情況而定，存取遺失可以是暫時性 （金鑰政策可以更正） 或永久 （無法還原已刪除的金鑰）。我們建議您[限制對關鍵操作的存取](https://docs.aws.amazon.com/kms/latest/developerguide/deleting-keys-adding-permission.html)，例如刪除或停用 AWS KMS 金鑰。此外，我們建議您的組織設定[AWS 中斷玻璃存取程序](https://docs.aws.amazon.com/wellarchitected/latest/devops-guidance/ag.sad.5-implement-break-glass-procedures.html)，以確保您的特權使用者在 Amazon Verified Permissions 無法存取 AWS 的罕見情況下可以存取 。

## 監控 Amazon Verified Permissions 與 的互動 AWS KMS
<a name="monitoring-kms-interaction"></a>

您可以透過 監控 Amazon Verified Permissions 對 的使用 客戶受管金鑰 AWS CloudTrail。 AWS KMS 透過 Verified Permissions 對 的每個請求都包含加密內容，以及請求參數中正在使用的金鑰 ARN （您的 客戶受管金鑰)：

的範例 AWS CloudTrail 日誌項目`GenerateDataKeyWithoutPlaintext`：

```
{  
    "eventVersion": "1.11",  
    "userIdentity": {  
        "type": "AWSService",  
        "invokedBy": "verifiedpermissions.amazonaws.com"  
    },  
    "eventTime": "2025-09-28T16:51:04Z",  
    "eventSource": "kms.amazonaws.com",  
    "eventName": "GenerateDataKeyWithoutPlaintext",  
    "awsRegion": "us-east-1",  
    "sourceIPAddress": "verifiedpermissions.amazonaws.com",  
    "userAgent": "verifiedpermissions.amazonaws.com",  
    "requestParameters": {  
        "keyId": "arn:aws:kms:us-east-1:111122223333:key/abcdefgh-0123-ijkl-4567-mnopqrstuvwx",  
        "encryptionContext": {  
            "aws:verifiedpermissions:policy-store-arn": "arn:aws:verifiedpermissions::111122223333:policy-store/PSt123456789012",  
            "policy_store_editor": "Janus"  
        },  
        ...  
    },  
    ...  
}
```

的範例 AWS CloudTrail 日誌項目`Decrypt`：

```
{  
    "eventVersion": "1.11",  
    "userIdentity": {  
        "type": "AWSService",  
        "invokedBy": "verifiedpermissions.amazonaws.com"  
    },  
    "eventTime": "2025-09-28T16:53:21Z",  
    "eventSource": "kms.amazonaws.com",  
    "eventName": "Decrypt",  
    "awsRegion": "us-east-1",  
    "sourceIPAddress": "verifiedpermissions.amazonaws.com",  
    "userAgent": "verifiedpermissions.amazonaws.com",  
    "requestParameters": {  
        "encryptionAlgorithm": "SYMMETRIC_DEFAULT",  
        "keyId": "arn:aws:kms:us-east-1:111122223333:key/abcdefgh-0123-ijkl-4567-mnopqrstuvwx",  
        "encryptionContext": {  
            "aws:verifiedpermissions:policy-store-arn": "arn:aws:verifiedpermissions::111122223333:policy-store/PSt123456789012",  
            "policy_store_owner": "Elias"  
        }  
    },  
    ...  
}
```

的範例 AWS CloudTrail 日誌項目`ReEncrypt`：

```
{  
    "eventVersion": "1.11",  
    "userIdentity": {  
        "type": "AWSService",  
        "invokedBy": "verifiedpermissions.amazonaws.com"  
    },  
    "eventTime": "2025-09-28T16:51:04Z",  
    "eventSource": "kms.amazonaws.com",  
    "eventName": "ReEncrypt",  
    "awsRegion": "us-east-1",  
    "sourceIPAddress": "verifiedpermissions.amazonaws.com",  
    "userAgent": "verifiedpermissions.amazonaws.com",  
    "requestParameters": {  
        "sourceKeyId": "arn:aws:kms:us-east-1:111122223333:key/abcdefgh-0123-ijkl-4567-mnopqrstuvwx",  
        "destinationEncryptionContext": {  
            "aws:verifiedpermissions:policy-store-arn": "arn:aws:verifiedpermissions::111122223333:policy-store/PSt123456789012"  
        },  
        "sourceEncryptionAlgorithm": "SYMMETRIC_DEFAULT",  
        "destinationKeyId": "arn:aws:kms:us-east-1:111122223333:key/abcdefgh-0123-ijkl-4567-mnopqrstuvwx",  
        "sourceEncryptionContext": {  
            "aws:verifiedpermissions:policy_store_arn": "arn:aws:verifiedpermissions::111122223333:policy-store/PSt123456789012"  
        },  
        "destinationEncryptionAlgorithm": "SYMMETRIC_DEFAULT",  
        ...  
    },  
    ...  
}
```

請注意，日誌項目包括`invokedBy`參考 Amazon Verified Permissions 的委託人，並`encryptionContext/sourceEncryptionContext/destinationEncryptionContext`包含在`requestParameters`映射中。

的範例 AWS CloudTrail 日誌項目`DescribeKey`：

```
{  
    "eventVersion": "1.11",  
    "userIdentity": {  
        "type": "AWSService",  
        "invokedBy": "verifiedpermissions.amazonaws.com"  
    },  
    "eventTime": "2025-09-28T16:51:02Z",  
    "eventSource": "kms.amazonaws.com",  
    "eventName": "DescribeKey",  
    "awsRegion": "us-east-1",  
    "sourceIPAddress": "verifiedpermissions.amazonaws.com",  
    "userAgent": "verifiedpermissions.amazonaws.com",  
    "requestParameters": {  
        "keyId": "arn:aws:kms:us-east-1:111122223333:key/abcdefgh-0123-ijkl-4567-mnopqrstuvwx"  
    },  
    ...  
}
```

請注意，日誌項目包含`invokedBy`參考 Amazon Verified Permissions 的委託人。

如需 AWS CloudTrail 日誌項目的詳細資訊，請參閱*AWS CloudTrail 《 使用者指南*》中的[了解 AWS CloudTrail 事件](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-events.html)。

## 限制
<a name="limitations"></a>

本主題說明 Verified Permissions 和使用 客戶受管金鑰進行資源加密的目前限制。
+ 一旦啟用，您就無法停用政策存放區的加密
+ 建立沒有加密的政策存放區之後，您無法更新要由 加密的政策存放區 客戶受管金鑰
+ 在您撤銷現有加密政策存放區對 客戶受管金鑰 的已驗證許可存取權後，可能會有過時的授權決策
+ 使用 建立政策存放區後 客戶受管金鑰，您無法修改自訂加密內容值；這些值是在加密政策存放區建立期間設定的靜態值

## 對 Amazon Verified Permissions 中的客戶受管金鑰進行故障診斷
<a name="troubleshoot-cmk"></a>

本主題說明使用 Amazon Verified Permissions 時可能遇到的常見 客戶受管金鑰 相關錯誤，並提供解決問題的疑難排解步驟。

### 拒絕存取： AWS KMS 許可問題
<a name="access-denied-kms-permission"></a>

**錯誤：**「服務或發起人無權使用提供的 AWS KMS 金鑰，因為資源不存在於此區域，沒有資源型政策允許存取，或資源型政策明確拒絕存取」

這可能表示服務或發起人在其 IAM 政策/AWS KMS 金鑰政策中缺少必要的`kms:*`動作許可，或參考的金鑰不存在或不再存在。

#### 使用 進行故障診斷 AWS CloudTrail：
<a name="troubleshooting-cloudtrail"></a>
+ 在 中尋找`kms.amazonaws.com`事件 AWS CloudTrail
+ 搜尋被識別為不允許 AWS KMS 的操作的事件名稱 （即 `Decrypt`、`ReEncrypt`、`GenerateDataKeyWithoutPlaintext`、 `DescribeKey`等）
+ 檢閱 `errorCode`和 `errorMessage` 欄位
+ 檢查 `userIdentity`以確認哪些委託人嘗試 操作

若要解決此問題，請在其 IAM 政策和 AWS KMS 金鑰政策中授予使用者或 IAM 委託人適當的 AWS KMS 操作存取許可。如需詳細資訊，請參閱[完成 AWS KMS 金鑰政策](#complete-kms-key-policy)。

### 驗證例外： AWS KMS 金鑰組態
<a name="validation-exception-kms-config"></a>

**錯誤：**「已設定的 AWS KMS 金鑰沒有有效的組態」

這表示由於目前組態，服務無法使用所參考的金鑰進行 客戶受管金鑰 加密。原因可能包括金鑰已停用、金鑰具有不支援的 EncryptionAlgorithm，或金鑰具有不支援的 KeyUsage 類型。

### 調節例外狀況： AWS KMS 速率限制
<a name="throttling-exception-kms-rate"></a>

**錯誤：**「您已超過可呼叫的速率 AWS KMS」

此錯誤表示您已超過金鑰的密碼編譯操作 AWS KMS 限制：https：//[https://docs.aws.amazon.com/kms/latest/developerguide/requests-per-second.html](https://docs.aws.amazon.com/kms/latest/developerguide/requests-per-second.html)。

## 相關資訊
<a name="related-information"></a>
+ [管理已驗證許可政策存放區](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/policy-stores.html)
+ [AWS KMS 最佳實務](https://docs.aws.amazon.com/kms/latest/developerguide/best-practices.html)
+ [AWS KMS 加密內容](https://docs.aws.amazon.com/kms/latest/developerguide/encrypt_context.html)
+ [AWS CloudTrail 整合](https://docs.aws.amazon.com/verifiedpermissions/latest/userguide/logging-monitoring.html)
+ [AWS CloudTrail 日誌項目範例](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-log-file-examples.html)