

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

# 管理对 Amazon Q 开发者版的访问权限以进行第三方集成
<a name="security_iam_manage-access-with-kms-policies"></a>

对于第三方集成，您必须使用 AWS 密钥管理服务 (KMS) 来管理对 Amazon Q Developer 的访问权限，而不是使用既不基于身份也不基于资源的 IAM 策略。

## 支持管理员使用客户自主管理型密钥来更新角色策略
<a name="kms-policy-examples-allow-access"></a>

以下示例密钥策略授予在 KMS 控制台中为已配置的角色创建密钥策略时使用[客户自主管理型密钥（CMK）](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html)的权限。配置 CMK 时，您必须提供 [IAM 角色 ARN](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-arns)（一个标识符），供您的集成用来调用 Amazon Q。如果您已经加入了集成（例如 GitLab 实例），则必须重新启动该实例，才能使用 CMK 对所有资源进行加密。

`kms:ViaService` 条件密钥将 KMS 密钥的使用限制为来自指定的 AWS 服务的请求。此外，也可以使用该条件密钥在请求来自特定服务时拒绝使用 KMS 密钥的权限。使用条件密钥，您可以限制谁可以使用 CMK 来加密或解密内容。有关更多信息，请参阅 *AWS Key Management Service 开发人员指南ViaService*[中的 kms:](https://docs.aws.amazon.com/kms/latest/developerguide/conditions-kms.html#conditions-kms-via-service)。

借助 KMS 加密上下文，您具有一组可选的密钥值对，可以将其包含在使用对称加密 KMS 密钥的加密操作中，以增强授权和可审计性。加密上下文可用于验证加密数据的完整性和真实性，控制对密钥策略和 IAM 策略中的对称加密 KMS 密钥的访问权限，以及在 AWS 日志中识别和分类加密操作。 CloudTrail 有关更多信息，请参阅《AWS Key Management Service Developer Guide》**中的 [Encryption context](https://docs.aws.amazon.com/kms/latest/developerguide/encrypt_context.html)。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "Sid0",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::111122223333:role/rolename"
            },
            "Action": [
                "kms:GenerateDataKeyWithoutPlaintext",
                "kms:Decrypt",
                "kms:ReEncryptFrom",
                "kms:ReEncryptTo",
                "kms:GenerateDataKey",
                "kms:Encrypt"
            ],
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "kms:ViaService": "q.us-east-1.amazonaws.com",
                    "kms:EncryptionContext:aws-crypto-ec:aws:qdeveloper:accountId": "111122223333"
                }
            }
        },
        {
            "Sid": "Sid1",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::111122223333:role/rolename"
            },
            "Action": "kms:DescribeKey",
            "Resource": "*"
        }
    ]
}
```

------