feat(project): add gateway resources - #2028
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## refactor #2028 +/- ##
============================================
+ Coverage 97.24% 97.30% +0.05%
============================================
Files 396 400 +4
Lines 24019 24531 +512
============================================
+ Hits 23357 23869 +512
Misses 662 662 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dbcb3b6 to
fd627a1
Compare
fd627a1 to
41a946d
Compare
41a946d to
7753af0
Compare
| ); | ||
| if (gatewayIndex < 0) { | ||
| throw new InputValidationError( | ||
| `gateway '${input.gatewayName}' does not exist in agentCoreGateways[]`, |
There was a problem hiding this comment.
nit: does not exist in project. Please check agentCoreGateway in agentcore.json
| }; | ||
| } | ||
|
|
||
| private assertUniqueGatewayTargetName(project: Project["spec"], name: string): void { |
There was a problem hiding this comment.
Are all gateway target names required to be unique across every gateway, or must they only be unique inside a single gateway?
| ), | ||
| flag( | ||
| "knowledge-base", | ||
| "project Knowledge Base name or external ten-character Knowledge Base ID", |
There was a problem hiding this comment.
add that this could only be used with bedrock-knowledge-base
| import type { Project } from "../../types"; | ||
| import type { AddProjectResourceConfig } from "../types"; | ||
|
|
||
| export const createAddGatewayTargetHandler = (config: AddProjectResourceConfig) => |
There was a problem hiding this comment.
If you check how the help looks for the old cli, you will notice that it divides based on target
Target types and their options:
http-runtime — Route to an AgentCore runtime
--runtime <name> Runtime from your project
--runtime-endpoint <name> Endpoint / version alias (optional)
mcp-server — Connect to an MCP-compatible server
--endpoint <url> Server endpoint URL
--host <host> Lambda or AgentCoreRuntime
--language <lang> Python, TypeScript, or Other
api-gateway — Connect to an Amazon API Gateway REST API
--rest-api-id <id> REST API ID
--stage <stage> Deployment stage
open-api-schema / smithy-model — Auto-derive tools from a schema
--schema <path> Schema file path or S3 URI
--schema-s3-account <id> S3 bucket owner account ID
lambda-function-arn — Connect to an AWS Lambda function
--lambda-arn <arn> Lambda function ARN
--tool-schema-file <path> Tool schema JSON file
connector — Wire a managed AWS connector (bedrock-knowledge-bases, web-search)
--connector <id> bedrock-knowledge-bases or web-search
--knowledge-base-id <id> Project KB name or 10-char external KB id (for KB connectors)
--exclude-domains <list> Comma-separated domains to exclude (for web-search connector)
passthrough — Route to an external HTTPS endpoint
--passthrough-endpoint <url> HTTPS endpoint URL
--stickiness-identifier <expr> Session routing expression (optional)
--stickiness-timeout <seconds> Sticky session timeout in seconds (optional)
Auth (--outbound-auth <type>, --credential-name <name>) — valid types per target:
mcp-server oauth or none
lambda-function-arn oauth or none
http-runtime oauth or none
open-api-schema oauth or api-key (required)
api-gateway api-key or none
smithy-model none (uses gateway IAM role)
passthrough gateway-iam-role, oauth, or jwt-passthrough
| configurations: [{ name: "WebSearch", parameterValues: { maxResults: 10 } }], | ||
| }; | ||
| case "bedrock-knowledge-bases": | ||
| if (!knowledgeBase) { |
There was a problem hiding this comment.
Don't we do this validation at line 60?
| ), | ||
| flag("exception-level", "exception detail level: debug", z.enum(["debug"]).optional()), | ||
| flag( | ||
| "tags", |
There was a problem hiding this comment.
Check runtime and harness, we don't do SourceResolver for this.
| "restrict Target protocols to MCP; omitted allows every Target protocol", | ||
| z.enum(["mcp"]).optional(), | ||
| ), | ||
| flag( |
There was a problem hiding this comment.
nit: The description should say enable semantic search to search tools on gateway
| z.string().optional(), | ||
| ), | ||
| flag( | ||
| "policy-engine-name", |
There was a problem hiding this comment.
Should we expand this for policy engines outside of this project? What is cons of doing that?
| testIO, | ||
| } from "../../../testing"; | ||
|
|
||
| export function createGatewayProjectTestHarness(directoryPrefix: string) { |
There was a problem hiding this comment.
combine this with index.test.ts. If no one other test file is using it, it should be combine with the test file
|
|
||
| export type RemoveResourceInput = { | ||
| resourceType: ProjectResource; | ||
| resourceType: Exclude<ProjectResource, "gateway" | "gateway-target">; |
There was a problem hiding this comment.
Why are we excluding it from remove?
Summary
Adds project-based Gateway mutation commands:
Project-command JSON maps directly to the existing version 1
agentcore.jsonschemas:--authorizer-configurationacceptsGatewayAuthorizerConfigSchema;--target-configurationaccepts one completeAgentCoreGatewayTargetSchemaobject;--connector-configurationaccepts the same complete Target object and requirestargetType: "connector";file://, and through stdin;Scalar endpoint, Runtime, and curated connector shortcuts remain. They construct the same
project-schema objects accepted through JSON.
The change also:
--enable-semantic-searchproject field;agentcore.jsonwrite;handled specially;
unassignedTargets[], matching the oldCLI and existing L3 output contract.
No project schema files change. The CLI does not create or copy files referenced by Target JSON;
paths such as
schemaSource.inline.pathandlambdaFunctionArn.toolSchemaFileremain explicit inagentcore.json.Testing
Rebased onto
upstream/refactorat38c30ae4; verification ran on PR head854514eb.bun run format:checkbun run lint:checkbun run typecheckbun test srcoutside the restricted sandbox: 1,789 passedbun run buildfile://, and through stdinunassignedTargets[]Live deployment
Earlier end-to-end verification of the same persisted Gateway shapes used a clean generated project
in account
603141041947, regionus-west-2, with@aws/agentcore-cdk@0.1.0-alpha.45.gateway-connector; synthesis produced the expected connectorconfiguration and IAM dependency. The service rejected live Target creation because
Connector integration web-search is not available for this account.SearchType: NONEwhen MCP semantic search is disabled, which currentCloudFormation rejects. The deployment fixture used
project add gateway --protocol mcp --enable-semantic-search, allowing deployment without changing the CLI or L3 dependency.READY.runtime-target/invocationsthrough the Gateway and received HTTP 200 withruntime gateway works.initializeandtools/listthrough the MCP Gateway; both returned HTTP 200 and thedirect DeepWiki Target tools were listed.
Targets return not-found.
Credential-provider authoring is owned by the separate project credentials commands. This PR
validates Gateway Target references to those project credentials but does not create them.