(aws-bedrockagentcore): support customer-managed KMS key (kmsKey) for Evaluator
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the feature
The `Evaluator` L2 construct in `aws-cdk-lib/aws-bedrockagentcore` does not expose a way to
configure a customer-managed AWS KMS key, even though the underlying
`AWS::BedrockAgentCore::Evaluator` resource supports a `KmsKeyArn` property. Today an
evaluator is always encrypted with an AWS-owned key, and the only workaround is to drop down
to the L1 `CfnEvaluator` escape hatch.
Other L2 constructs in the same module already expose this capability: both `Gateway` and
`PolicyEngine` accept a `kmsKey: IKey` prop.
### Use Case
Customers with encryption-at-rest / compliance requirements (regulated industries, internal
data-governance policies) need to encrypt evaluator configuration (LLM-as-a-Judge
instructions, rating scales, code-based evaluator config) with their own customer-managed key
(CMK) so that they control key rotation, access, and revocation. This is currently not
possible through the L2 API without resorting to the L1 escape hatch.
### Proposed Solution
Add an optional `kmsKey?: kms.IKey` to `EvaluatorProps` and forward its ARN to the L1 resource:
```ts
const evaluator = new agentcore.Evaluator(this, 'MyEvaluator', {
evaluatorName: 'my_evaluator',
level: agentcore.EvaluationLevel.SESSION,
evaluatorConfig: agentcore.EvaluatorConfig.llmAsAJudge({ /* ... */ }),
kmsKey: myKey, // NEW
});
```
Implementation sketch (in
`packages/aws-cdk-lib/aws-bedrockagentcore/lib/evaluation/custom-evaluator.ts`):
- Add `readonly kmsKey?: kms.IKey;` to `EvaluatorProps`, documented with
`@default - an AWS owned key is used` (mirrors the existing `Gateway` / `PolicyEngine` docs).
- Forward `kmsKeyArn: props.kmsKey?.keyArn` into `new CfnEvaluator(...)`.
- Optionally expose `public readonly kmsKey?: kms.IKey` on the construct (as `Gateway` does).
This is backward compatible: when `kmsKey` is omitted, `KmsKeyArn` is absent from the
synthesized template and behavior is unchanged.
**Open question (would appreciate maintainer guidance):** unlike `Gateway` and `Memory`, the
`Evaluator` construct does not own an execution role, so there is no IAM principal for the L2
to `grantEncryptDecrypt` on the key. Should the L2 (a) leave key-policy management entirely to
the user, or (b) add a key resource-policy statement allowing the `bedrock-agentcore` service
principal to use the key (ideally with a `kms:ViaService` condition)? Happy to follow whichever
convention maintainers prefer.
### Other Information
- CloudFormation reference: [`AWS::BedrockAgentCore::Evaluator`](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-bedrockagentcore-evaluator.html) → `KmsKeyArn`.
- Precedent in the same module: `Gateway.kmsKey` and `PolicyEngine.kmsKey` (both already accept `kms.IKey`).
### Acknowledgements
- [x] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### AWS CDK Library version (aws-cdk-lib)
2.259.0
### AWS CDK CLI version
2.1126.0
### Environment details (OS name and version, etc.)
macOS 26 (arm64)
Contributor guide
Research direction
Start with packages/aws-cdk-lib/aws-bedrockagentcore/lib/evaluation/custom-evaluator.ts and compare the kmsKey handling in the Gateway and PolicyEngine constructs. Inspect how CfnEvaluator is configured and determine the maintainers' preferred key-policy treatment for the bedrock-agentcore service. Done means EvaluatorProps accepts an optional IKey, its ARN reaches KmsKeyArn when provided, and omission preserves the current synthesized template.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, security
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100