feat(evaluator): add kmsKeyArn support for custom evaluator#994
feat(evaluator): add kmsKeyArn support for custom evaluator#994aws-aditya21 wants to merge 1 commit intomainfrom
Conversation
Coverage Report
|
ba4c55c to
fe5cd4b
Compare
|
Field naming inconsistency: Other primitives in both Additionally, CFN uses Options:
Please confirm the field name with the companion CDK PR before merging, since whatever is in |
|
Unsafe cast in
kmsKeyArn: (response as unknown as Record<string, unknown>).kmsKeyArn as string | undefined,This double-cast bypasses TypeScript's checking of the SDK response type. Compare with how Given that CFN exposes this as Options:
Either way, please verify by inspecting the actual |
|
KMS key ARN validation regex is too restrictive The regex used in both will reject several valid KMS key ARN formats:
Additionally, duplicating the same regex in two places risks them drifting; consider extracting to a shared helper (e.g. Options:
|
|
|
Reviewed the PR. The three existing automation comments (field naming |
fe5cd4b to
9bc2d70
Compare
9bc2d70 to
efd4b07
Compare
efd4b07 to
6d2c475
Compare
|
|
||
| if ( | ||
| cliOptions.kmsKeyArn && | ||
| !/^arn:aws(?:|-cn|-us-gov):kms:[a-zA-Z0-9-]*:[0-9]{12}:key\/[a-zA-Z0-9-]{36}$/.test( |
There was a problem hiding this comment.
This should be a shared constant between EvaluatorPrimitive.ts and AddEvaluatorScreen.tsx
There was a problem hiding this comment.
Thanks for the suggestion Done extracted accordingly
|
|
||
| if ( | ||
| cliOptions.kmsKeyArn && | ||
| !/^arn:aws(?:|-cn|-us-gov):kms:[a-zA-Z0-9-]*:[0-9]{12}:key\/[a-zA-Z0-9-]{36}$/.test( |
There was a problem hiding this comment.
instead of this validation, can we do /^arn:[^:]+:kms:[a-zA-Z0-9-]*:[0-9]{12}:key\/[a-zA-Z0-9-]{36}$/ as mentioned in the AGENTS.md?
| level: EvaluationLevelSchema, | ||
| description: z.string().optional(), | ||
| config: EvaluatorConfigSchema, | ||
| kmsKeyArn: z.string().optional(), |
There was a problem hiding this comment.
can we add some regex validation here so malformed ARNs are caught early?
There was a problem hiding this comment.
added kmskeyarnschema with regex validation.
6d2c475 to
1cb1454
Compare
Description
Add optional
kmsKeyArnsupport for custom evaluators, enabling customers to specify a KMS key for evaluator encryption at rest.Changes (9 files)
src/schema/schemas/agentcore-project.ts— addedkmsKeyArntoEvaluatorSchemasrc/cli/primitives/EvaluatorPrimitive.ts— added--kms-key-arnCLI flag, updated options, action handler, andcreateEvaluatorsrc/cli/tui/screens/evaluator/types.ts— addedkms-key-arnstep andkmsKeyArntoAddEvaluatorConfigsrc/cli/tui/screens/evaluator/useAddEvaluatorWizard.ts— added KMS state, callback, wired into all wizard flowssrc/cli/tui/screens/evaluator/AddEvaluatorScreen.tsx— added KMS key ARN text input and confirm fieldsrc/cli/tui/hooks/useCreateEvaluator.ts— passeskmsKeyArnthrough to primitivesrc/cli/commands/import/import-evaluator.ts—toEvaluatorSpecforwardskmsKeyArnfrom API responsesrc/cli/aws/agentcore-control.ts— addedkmsKeyArntoGetEvaluatorResultsrc/cli/commands/import/__tests__/import-evaluator.test.ts— added tests forkmsKeyArnforwardingCompanion PR
CDK constructs: https://github.com/aws/agentcore-l3-cdk-constructs/pull/184
CFN support for
EncryptionKeyArnonAWS::BedrockAgentCore::Evaluatoris assumed ready per service team confirmation.Closes #
Type of Change
Testing
How have you tested the change?
npm run test:unitandnpm run test:integnpm run typechecknpm run lintsrc/assets/, I rannpm run test:update-snapshotsand committed the updated snapshotsChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.