

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

# 加密 2025 年 1 月 22 日之前创建的代理的代理资源
<a name="encryption-agents"></a>

**重要**  
如果您是在 2025 年 1 月 22 日*之后*创建的代理，请按照[代理资源的加密](encryption-agents-new.md)中的说明进行操作。

Amazon Bedrock 会加密代理的会话信息。默认情况下，Amazon Bedrock 使用AWS托管密钥对这些数据进行加密。或者，您可以使用客户托管式密钥来加密代理构件。

有关更多信息AWS KMS keys，请参阅《*AWS Key Management Service开发人员指南》*中的[客户托管密钥](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#customer-cmk)。

如果使用自定义 KMS 密钥加密与代理的会话，则必须设置以下基于身份的策略和基于资源的策略，以允许 Amazon Bedrock 代表您加密和解密代理资源。

1. 将以下基于身份的策略附加到具有 `InvokeAgent` 调用权限的 IAM 角色或用户。此策略会验证发出 `InvokeAgent` 调用的用户是否具有 KMS 权限。将 *\$1\$1region\$1*、*\$1\$1account-id\$1*、*\$1\$1agent-id\$1* 和 *\$1\$1key-id\$1* 替换为相应值。

------
#### [ JSON ]

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Sid": "EncryptDecryptAgents",
               "Effect": "Allow",
               "Action": [
                   "kms:GenerateDataKey",
                   "kms:Decrypt"
               ],
               "Resource": "arn:aws:kms:us-east-1:123456789012:key/key-id",
               "Condition": {
                   "StringEquals": {
                       "kms:EncryptionContext:aws:bedrock:arn": "arn:aws:bedrock:us-east-1:123456789012:agent/agent-id"
                   }
               }
           }
       ]
   }
   ```

------

1. 将以下基于资源的策略附加到 KMS 密钥。根据需要更改权限的范围。将 *\$1\$1region\$1*、*\$1\$1account-id\$1*、*\$1\$1agent-id\$1* 和 *\$1\$1key-id\$1* 替换为相应值。

------
#### [ JSON ]

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Sid": "AllowRootModifyKMSKey",
               "Effect": "Allow",
               "Principal": {
                   "AWS": "arn:aws:iam::123456789012:root"
               },
               "Action": "kms:*",
               "Resource": "arn:aws:kms:us-east-1:123456789012:key/KeyId"
           },
           {
               "Sid": "AllowBedrockEncryptAgent",
               "Effect": "Allow",
               "Principal": {
                   "Service": "bedrock.amazonaws.com"
               },
               "Action": [
                   "kms:GenerateDataKey",
                   "kms:Decrypt"
               ],
               "Resource": "arn:aws:kms:us-east-1:123456789012:key/KeyId",
               "Condition": {
                   "StringEquals": {
                       "kms:EncryptionContext:aws:bedrock:arn": "arn:aws:bedrock:us-east-1:123456789012:agent/AgentId"
                   }
               }
           },
           {
               "Sid": "AllowRoleEncryptAgent",
               "Effect": "Allow",
               "Principal": {
                   "AWS": "arn:aws:iam::123456789012:role/Role"
               },
               "Action": [
                   "kms:GenerateDataKey*",
                   "kms:Decrypt"
               ],
               "Resource": "arn:aws:kms:us-east-1:123456789012:key/KeyId"
           },
           {
               "Sid": "AllowAttachmentPersistentResources",
               "Effect": "Allow",
               "Principal": {
                   "Service": "bedrock.amazonaws.com"
               },
               "Action": [
                   "kms:CreateGrant",
                   "kms:ListGrants",
                   "kms:RevokeGrant"
               ],
               "Resource": "*",
               "Condition": {
                   "Bool": {
                       "kms:GrantIsForAWSResource": "true"
                   }
               }
           }
       ]
   }
   ```

------